I have a data set for exploration. There are some string variables as well as integer variables.
For the integer variables, I have to convert them to numeric. How do i transform the string variables?
I have a data set for exploration. There are some string variables as well as integer variables.
For the integer variables, I have to convert them to numeric. How do i transform the string variables?
If you want to change the class of data, you can convert int
to num
using the following. Note that you need to select the columns that you want to change. This answer came from here
cols = c(1, 3, 4, 5);
df[,cols] = apply(df[,cols], 2, function(x) as.numeric(as.character(x)));