mush_1 <- mushrooms[,1:4]
mush_2 <- mushrooms[,6]
#the two are combined into one
mushs <- cbind(mush_1, mush_2)
head(mushs)
| V1 | V2 | V3 | V4 | mush_2 |
|---|---|---|---|---|
| p | x | s | n | p |
| e | x | s | y | a |
| e | b | s | w | l |
| p | x | y | w | p |
| e | x | s | g | n |
| e | x | y | y | a |
colnames(mushs) <- c("Edible/Poisonous","Cap-Shape","Cap-Surface","Cap-Color","Odor")
head(mushs)
| Edible/Poisonous | Cap-Shape | Cap-Surface | Cap-Color | Odor |
|---|---|---|---|---|
| p | x | s | n | p |
| e | x | s | y | a |
| e | b | s | w | l |
| p | x | y | w | p |
| e | x | s | g | n |
| e | x | y | y | a |
#Edible/Poisonous
levels(mushs$'Edible/Poisonous') <- c(levels(mushs$'Edible/Poisonous'), c("Edible","Poisonous"))
mushs$'Edible/Poisonous' <-
mushs$'Edible/Poisonous'[mushs$'Edible/Poisonous' == "e"] <- "Edible"
mushs$'Edible/Poisonous'[mushs$'Edible/Poisonous' == "p"] <- "Poisonous"
#Cap-Shape
levels(mushs$`Cap-Shape`) <- c(levels(mushs$`Cap-Shape`), c("Bell","Conical","Convex","Flat","Knobbed","Sunken"))
mushs$`Cap-Shape`[mushs$`Cap-Shape` == "b"] <- "Bell"
mushs$`Cap-Shape`[mushs$`Cap-Shape` == "c"] <- "Conical"
mushs$`Cap-Shape`[mushs$`Cap-Shape` == "x"] <- "Convex"
mushs$`Cap-Shape`[mushs$`Cap-Shape` == "f"] <- "Flat"
mushs$`Cap-Shape`[mushs$`Cap-Shape` == "k"] <- "Knobbed"
mushs$`Cap-Shape`[mushs$`Cap-Shape` == "s"] <- "Sunken"
#Cap-Surface
levels(mushs$`Cap-Surface`) <- c(levels(mushs$`Cap-Surface`), c("Fibrous", "Grooves", "Scaly", "Smooth"))
mushs$`Cap-Surface`[mushs$`Cap-Surface` == "f"] <- "Fibrous"
mushs$`Cap-Surface`[mushs$`Cap-Surface` == "g"] <- "Grooves"
mushs$`Cap-Surface`[mushs$`Cap-Surface` == "y"] <- "Scaly"
mushs$`Cap-Surface`[mushs$`Cap-Surface` == "s"] <- "Smooth"
#Cap-Color
levels(mushs$`Cap-Color`) <- c(levels(mushs$`Cap-Color`), c("Brown", "Buff", "Cinnamon", "Gray", "Green", "Pink", "Purple", "Red", "White", "Yellow"))
mushs$`Cap-Color`[mushs$`Cap-Color` == "n"] <- "Brown"
mushs$`Cap-Color`[mushs$`Cap-Color` == "b"] <- "Buff"
mushs$`Cap-Color`[mushs$`Cap-Color` == "c"] <- "Cinnamon"
mushs$`Cap-Color`[mushs$`Cap-Color` == "g"] <- "Gray"
mushs$`Cap-Color`[mushs$`Cap-Color` == "r"] <- "Green"
mushs$`Cap-Color`[mushs$`Cap-Color` == "p"] <- "Pink"
mushs$`Cap-Color`[mushs$`Cap-Color` == "u"] <- "Purple"
mushs$`Cap-Color`[mushs$`Cap-Color` == "e"] <- "Red"
mushs$`Cap-Color`[mushs$`Cap-Color` == "w"] <- "White"
mushs$`Cap-Color`[mushs$`Cap-Color` == "y"] <- "Yellow"
#Odor
levels(mushs$Odor) <- c(levels(mushs$Odor), c("Almond", "Anise", "Creosote", "Fishy", "Foul", "Musty", "None", "Pungent", "Spicy"))
mushs$Odor[mushs$Odor == "a"] <- "Almond"
mushs$Odor[mushs$Odor == "l"] <- "Anise"
mushs$Odor[mushs$Odor == "c"] <- "Creosote"
mushs$Odor[mushs$Odor == "y"] <- "Fishy"
mushs$Odor[mushs$Odor == "f"] <- "Foul"
mushs$Odor[mushs$Odor == "m"] <- "Musty"
mushs$Odor[mushs$Odor == "n"] <- "None"
mushs$Odor[mushs$Odor == "p"] <- "Pungent"
mushs$Odor[mushs$Odor == "s"] <- "Spicy"
head(mushs)
| Edible/Poisonous | Cap-Shape | Cap-Surface | Cap-Color | Odor |
|---|---|---|---|---|
| Edible | Convex | Smooth | Brown | Pungent |
| Edible | Convex | Smooth | Yellow | Almond |
| Edible | Bell | Smooth | White | Anise |
| Edible | Convex | Scaly | White | Pungent |
| Edible | Convex | Smooth | Gray | None |
| Edible | Convex | Scaly | Yellow | Almond |