Categorical Data
Categorical Data
- Here in Data.csv, two column are Categorical Data
- Country (France / Spain /Germany)
- Purchased (YES/NO)
- So we want to make categorical data.
#categorical data
dataset$Country = factor ( dataset$Country,
levels = c('France','Spain','Germany'),
labels = c(1,2,3))
dataset$Purchased =factor( dataset$Purchased ,
levels =c('Yes','No'),
labels = c(1,0))
- Just add this line of code and run it, observe dataset variable. It assigns
- country column 1,2,3 to France, Spain, Germany.
- purchased column 1,0 to Yes, No.
Comments
Post a Comment