Encoding Categorical Data in R for Data Science - Detechtor

#artificialintelligence 

We've learned how to install R and RStudio, import the dataset, and take care of missing data using the R language. Now I'm going you show you how to encode categorical data in R. If you take a look at our dataset, you'll see that we have two categorical variables. We have the county variables – Nairobi, Kisumu, and Mombasa – and we have the Purchased variables – Yes and No. They're categorical variables, obviously because they have categories. Since machine learning models are based on mathematical/numerical equations, keeping the text in the categorical variables would definitely cause us some problems. We want to have'numbers only' in our equations.