I'm using R and I have a dataset with about 450 columns and I'm trying to figure out how to loop through all the columns and then if that column's values are categorical then recode that column's values.
attach(my_data)
for(i in names(my_data)){
# how to check the data of each column
my_data[[my_data[[i]]]] <- as.numeric(my_data[[i]])
}
That's what I've been able to work out so far, but I'm not sure how to check the data of each column.