DATA 602 : Assignment 1: Mushroom Database

Load the mushroom database

library(RCurl)
## Loading required package: bitops
mushroom <- read.csv('https://archive.ics.uci.edu/ml/machine-learning-databases/mushroom/agaricus-lepiota.data', header=FALSE)
head(mushroom)
##   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

Subset the data with columns I am interested in and Assign proper names

library(plyr)
mushroom <- mushroom[, c(1,2,4,20,22)]
#mushroom
mushroom <- rename(mushroom, c("V1"="Type", "V2"="CapShpe", "V4"="Color"))
mushroom <- rename(mushroom, c("V20"="RingType", "V22"="Population"))
head(mushroom)
##   Type CapShpe Color RingType Population
## 1    p       x     n        p          s
## 2    e       x     y        p          n
## 3    e       b     w        p          n
## 4    p       x     w        p          s
## 5    e       x     g        e          a
## 6    e       x     y        p          n

Map the values in DB to meaningful values

mushroom$Type <- mapvalues(mushroom$Type, from=c("p", "e"), to=c("poisonous", "edible"))

mushroom$CapShpe <- mapvalues(mushroom$CapShpe, from=c("b", "c", "x", "f", "k", "s"), to=c("bell","conical","convex","flat","knobbed","sunken"))

mushroom$Color <- mapvalues(mushroom$Color, from=c("n", "b", "c", "g", "r", "p", "u", "e", "w", "y"), to=c("brown","buff","cinnamon","gray","green","pink","purple","red","white","yellow"))

mushroom$RingType <- mapvalues(mushroom$RingType, from=c("c", "e", "f", "l", "n", "p", "s", "z"), to=c("cobwebby","evanescent","flaring","large","none","pendant","sheathing","zone"))
## The following `from` values were not present in `x`: c, s, z
mushroom$Population <- mapvalues(mushroom$Population, from=c("a", "c", "n", "s", "v", "y"), to=c("abundant","clustered","numerous","scattered","several","solitary"))


head(mushroom, n=40)
##         Type CapShpe  Color   RingType Population
## 1  poisonous  convex  brown    pendant  scattered
## 2     edible  convex yellow    pendant   numerous
## 3     edible    bell  white    pendant   numerous
## 4  poisonous  convex  white    pendant  scattered
## 5     edible  convex   gray evanescent   abundant
## 6     edible  convex yellow    pendant   numerous
## 7     edible    bell  white    pendant   numerous
## 8     edible    bell  white    pendant  scattered
## 9  poisonous  convex  white    pendant    several
## 10    edible    bell yellow    pendant  scattered
## 11    edible  convex yellow    pendant   numerous
## 12    edible  convex yellow    pendant  scattered
## 13    edible    bell yellow    pendant  scattered
## 14 poisonous  convex  white    pendant    several
## 15    edible  convex  brown evanescent   abundant
## 16    edible  sunken   gray    pendant   solitary
## 17    edible    flat  white evanescent   abundant
## 18 poisonous  convex  brown    pendant  scattered
## 19 poisonous  convex  white    pendant  scattered
## 20 poisonous  convex  brown    pendant  scattered
## 21    edible    bell yellow    pendant  scattered
## 22 poisonous  convex  brown    pendant    several
## 23    edible    bell yellow    pendant  scattered
## 24    edible    bell  white    pendant   numerous
## 25    edible    bell  white    pendant  scattered
## 26 poisonous    flat  white    pendant    several
## 27    edible  convex yellow    pendant   numerous
## 28    edible  convex  white    pendant   numerous
## 29    edible    flat  brown    pendant   solitary
## 30    edible  convex yellow    pendant    several
## 31    edible    bell yellow    pendant   numerous
## 32 poisonous  convex  white    pendant  scattered
## 33    edible  convex yellow    pendant   numerous
## 34    edible  convex  brown    pendant   solitary
## 35    edible    bell yellow    pendant  scattered
## 36    edible  convex yellow    pendant    several
## 37    edible  sunken   gray    pendant    several
## 38 poisonous  convex  brown    pendant  scattered
## 39    edible  convex yellow    pendant    several
## 40    edible    bell yellow    pendant  scattered