# When to choose character instead of factor in R?

I am currently working on a dataset which contains a name attribute, which stands for a person's first name. After reading the csv file with read.csv, the variable is a factor by default (stringsAsFactors=TRUE) with ~10k levels. Since name does not reflect any group membership, I am uncertain to leave it as factor.

Is it necessary to convert name to character? Are there some advantages in doing (or not doing) this? Does it even matter?

• Character is a string form while factor is a nominal label. – user19196 Jun 1 '16 at 18:21

Store them as whatever makes the most sense for what the data represent. If name is not categorical, and it sounds like it isn't, then use character.
• I would also add that if/when the character value itself (string) is of interest to you, for instance if you want to perform substring or regular expressions, you should consider text to avoir multiply calls to as.character(). – Eric Lecoutre Jun 2 '16 at 6:31