3.4 Changing data types
States and Gapminder
Sometimes you need to change the data type in R. Most of the variables in States and Gapminder are numeric variables, R’s term for continuous or quantitative variables. Some are listed as chr, character variables. We may want to use one of these variables as a categorical variable for analysis. R’s term for these variables is a factor. Region in Gapminder is an example.
This variable is now a factor and can be used in graphs and data analysis. Make sure you save your dataset after doing this so you don’t have to repeat this process.