# Load required libraries
library(plyr)
library(ggplot2)
library(knitr)
library(RCurl)
## Loading required package: bitops
myfile <- getURL('https://raw.githubusercontent.com/maelillien/data607-assignment1/master/agaricus-lepiota.data', ssl.verifyhost=FALSE, ssl.verifypeer=FALSE)
mushroom_data <- read.csv(textConnection(myfile), header=FALSE)
head(mushroom_data)
## V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20
## 1 p x s n t p f c n k e e s s w w p w o p
## 2 e x s y t a f c b k e c s s w w p w o p
## 3 e b s w t l f c b n e c s s w w p w o p
## 4 p x y w t p f c n n e e s s w w p w o p
## 5 e x s g f n f w b k t e s s w w p w o e
## 6 e x y y t a f c b n e c s s w w p w o p
## V21 V22 V23
## 1 k s u
## 2 n n g
## 3 n n m
## 4 k s u
## 5 n a g
## 6 k n g
mushroom_subset <- mushroom_data[,c(1:4,6)]
mushroom_subset <- rename(mushroom_subset, c("V1"="type","V2"="capshape","V3"="capsurface","V4"="capcolor","V6"="odor"))
mushroom_subset$type <- factor(c("p","e"))
levels(mushroom_subset$type) <- list(poisonous="p",edible="e")
mushroom_subset$capshape <- factor(c("b","c","x","f","k","s"))
levels(mushroom_subset$capshape) <- list(bell="b",conical="c",convex="x",flat="f",knobbed="k",sunken="s")
mushroom_subset$capsurface <- factor(c("f","g","y","s"))
levels(mushroom_subset$capsurface) <- list(fibrous="f",grooves="g",scaly="y",smooth="s")
mushroom_subset$capcolor <- factor(mushroom_subset$capcolor, c("n","b","c","g","r","p","u","e","w","y"), ordered=FALSE)
levels(mushroom_subset$capcolor) <- list(brown="n",buff="b",cinnamon="c",gray="g",green="r",pink="p",purple="u",red="e",white="w",yellow="y")
mushroom_subset$odor <- factor(mushroom_subset$odor, c("a","l","c","y","f","m","n","p","s"), ordered=FALSE)
levels(mushroom_subset$odor) <- list(almond="a",anise="l",creosote="c",fishy="y",foul="f",musty="m",none="n",pungent="p",spicy="s")
head(mushroom_subset)
## type capshape capsurface capcolor odor
## 1 poisonous bell fibrous brown pungent
## 2 edible conical grooves yellow almond
## 3 poisonous convex scaly white anise
## 4 edible flat smooth white pungent
## 5 poisonous knobbed fibrous gray none
## 6 edible sunken grooves yellow almond