R Program to Convert Factors to Characters

Example: Convert Factors to Characters in R

factor1 <- factor(c("Male", "Female", "Transgender"))
  
# convert factor to character 
result <- as.character(factor1)
  
print(result)

Output

[1] "Male"        "Female"      "Transgender"

In the above example, we have used the as.character() function to convert the factor named factor1 to character.

As we can see, each element of factor1 is displayed separately as a character.

Your builder path starts here. Builders don't just know how to code, they create solutions that matter.

Escape tutorial hell and ship real projects.

Try Programiz PRO
  • Real-World Projects
  • On-Demand Learning
  • AI Mentor
  • Builder Community