Some data carpentry is necessary to get the StatCan data into data types that sort consistently (age categories import as strings, but with no padding so in an alpha sort "1 year" is followed by "10 years", not "2 years"). The initial solution (which works) has been to strip the strings of the alphabetic and space characters, and convert the remainder to an integer.
But: is there a factor solution, using the funtions in forcats?
Some data carpentry is necessary to get the StatCan data into data types that sort consistently (age categories import as strings, but with no padding so in an alpha sort "1 year" is followed by "10 years", not "2 years"). The initial solution (which works) has been to strip the strings of the alphabetic and space characters, and convert the remainder to an integer.
But: is there a factor solution, using the funtions in
forcats
?