#Loading Mushroom Dataset.
library(plyr)
MushroomsOriginal <-read.csv(url("https://archive.ics.uci.edu/ml/machine-learning-databases/mushroom/agaricus-lepiota.data"))
#Creating data frame and selecting a subset of the data to transform.
mushrooms <-as.data.frame(MushroomsOriginal)
someshrooms <- mushrooms [1:100, 1:6]
#Naming columns
names(someshrooms) = c("classes", "cap-shape", "cap-surface", "cap-color", "bruises", "odor")
head(someshrooms)
## classes cap-shape cap-surface cap-color bruises odor
## 1 e x s y t a
## 2 e b s w t l
## 3 p x y w t p
## 4 e x s g f n
## 5 e x y y t a
## 6 e b s w t a
#Replacing abriviated values with full text
someshrooms$classes <-revalue(someshrooms$classes, c("e"="edible", "p"="poisonous"))
someshrooms$"cap-shape" <-revalue(someshrooms$"cap-shape", c("b"="bell", "c" = "conical", "x" = "convex", "f" = "flat", "k" = "knobbed", "s"= "sunken"))
head(someshrooms)
## classes cap-shape cap-surface cap-color bruises odor
## 1 edible convex s y t a
## 2 edible bell s w t l
## 3 poisonous convex y w t p
## 4 edible convex s g f n
## 5 edible convex y y t a
## 6 edible bell s w t a