Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in R Programming by (7.3k points)
Can anyone tell me what is a factor in R programming?

1 Answer

0 votes
by (41.4k points)

In R programming, factors are the data type that represents different categories of values present in the data that are called categorical values. These categorical values are stored as levels. The factor data type supports storing both integers and strings. It is helpful while dealing with columns that contain a different set of unique values. Also, there are more data types such as character, numeric, vector, and int. You can convert factor to character and character to factor using the below queries, respectively:

  1. as.factor("Name of column")
  2. as.character("Name of column")

You can convert factor to character because of the non-mutable property of the factor data type.

If you are looking for an online course to learn R programming, check out this R Programming Course by Intellipaat.

Browse Categories