Answers for "make a variable a factor in r"

R
1

How to Convert a Factor in R

> directions <- c("North", "East", "South", "South")
> directions.factor <- factor(directions)
> directions.factor
[1] North East South South
Levels: East North South
Posted by: Guest on December-21-2020
0

factor in r

# This returns a character vector, the as.numeric() function
# is still required to convert the values to the proper type (numeric).
f <- levels(f)[f]
f <- as.numeric(f)
Posted by: Guest on February-04-2021

Code answers related to "make a variable a factor in r"

Browse Popular Code Answers by Language