I have data.frame with almost 200 variables (columns) and different data types (num, int, logi, factor). Now I would like to remove all variables of type "factor" to run the cor () function
When I use the str () function, I can see which variables are of type “factor”, but I don’t know how to select and delete all these variables, because deleting one by one takes a lot of time. To select these variables, I tried attr () and typeof () with no results.
Which direction?
Assuming generic data.frame, this will remove columns of typefactor
data.frame
factor
df[,-which(sapply(df, class) == "factor")]
EDIT
@Roland , factor. .
df[, sapply(df, class) != "factor"]
2
cor, @Ista , is.numeric. factor.
cor
is.numeric
df[,sapply(df, is.numeric)]