Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Changing column data types
4. Convert characters to factors
Basic data cleaning


What about the gender column? We have here only two options: "Female" or "Male". This should be a factor, but it isn't. We'll need to change that too. As you can probably guess there is a function to do that: as.factor(). It works exactly like the as.character() function we just discussed:

survey$gender <- as.factor(survey$gender)


We have another column with only two possible answers: the vegetarian column. If someone is vegetarian, this column will have a "yes"; if not, it will store a "no". Change vegetarian from a character column to a factor using the as.factor() function.