to.factor | R Documentation |
Loops through columsn in dataframe and coerces them to type "factor"
.
to.factor(df, id = NULL)
df |
a matrix or dataframe. |
id |
a vector specifying the columns (by name or index) to be converted. The default will convert all columns. |
A dataframe
Jason Grafmiller
as.factor
, is.factor
, to.numeric
df <- mtcars
summary(df)
df <- to.factor(df, c("cyl", "gear", "carb"))
# or alternatively
# df <- to.factor(df, c(2, 10:11))
summary(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.