library(RCurl)
## Loading required package: bitops
mushroomInfo <- read.csv(text=getURL("https://archive.ics.uci.edu/ml/machine-learning-databases/mushroom/agaricus-lepiota.data"), header=FALSE, sep = ",")
#Took these attribute names from the archive page
names(mushroomInfo)<- c('class','capshape','capsurface','capcolor','bruises','odor','gillattachment','gillspacing','gillsize','gillcolor','stalkshape','stalkroot','stalksurfaceabovering','stalksurfacebelowring','stalkcolorabovering','stalkcolorbelowring','veiltype','veilcolor','ringnumber','ringtype','sporeprintcolor','population','habitat')
summary(mushroomInfo)
## class capshape capsurface capcolor bruises odor
## e:4208 b: 452 f:2320 n :2284 f:4748 n :3528
## p:3916 c: 4 g: 4 g :1840 t:3376 f :2160
## f:3152 s:2556 e :1500 s : 576
## k: 828 y:3244 y :1072 y : 576
## s: 32 w :1040 a : 400
## x:3656 b : 168 l : 400
## (Other): 220 (Other): 484
## gillattachment gillspacing gillsize gillcolor stalkshape stalkroot
## a: 210 c:6812 b:5612 b :1728 e:3516 ?:2480
## f:7914 w:1312 n:2512 p :1492 t:4608 b:3776
## w :1202 c: 556
## n :1048 e:1120
## g : 752 r: 192
## h : 732
## (Other):1170
## stalksurfaceabovering stalksurfacebelowring stalkcolorabovering
## f: 552 f: 600 w :4464
## k:2372 k:2304 p :1872
## s:5176 s:4936 g : 576
## y: 24 y: 284 n : 448
## b : 432
## o : 192
## (Other): 140
## stalkcolorbelowring veiltype veilcolor ringnumber ringtype
## w :4384 p:8124 n: 96 n: 36 e:2776
## p :1872 o: 96 o:7488 f: 48
## g : 576 w:7924 t: 600 l:1296
## n : 512 y: 8 n: 36
## b : 432 p:3968
## o : 192
## (Other): 156
## sporeprintcolor population habitat
## w :2388 a: 384 d:3148
## n :1968 c: 340 g:2148
## k :1872 n: 400 l: 832
## h :1632 s:1248 m: 292
## r : 72 v:4040 p:1144
## b : 48 y:1712 u: 368
## (Other): 144 w: 192
sub.m_Info <- subset(mushroomInfo, select = c(class, ringtype, population, habitat))
summary(sub.m_Info)
## class ringtype population habitat
## e:4208 e:2776 a: 384 d:3148
## p:3916 f: 48 c: 340 g:2148
## l:1296 n: 400 l: 832
## n: 36 s:1248 m: 292
## p:3968 v:4040 p:1144
## y:1712 u: 368
## w: 192
#Changing variables for subsets
sub.m_Info$class <- as.character(sub.m_Info$class)
sub.m_Info$class[sub.m_Info$class == 'e'] <- 'Edible'
sub.m_Info$class[sub.m_Info$class == 'p'] <- 'Poisonous'
sub.m_Info$class <- as.factor(sub.m_Info$class)
sub.m_Info$ringtype <- as.character(sub.m_Info$ringtype)
sub.m_Info$ringtype[sub.m_Info$ringtype == 'c'] <- 'Cobwebby'
sub.m_Info$ringtype[sub.m_Info$ringtype == 'e'] <- 'Evanescent'
sub.m_Info$ringtype[sub.m_Info$ringtype == 'f'] <- 'Flaring'
sub.m_Info$ringtype[sub.m_Info$ringtype == 'l'] <- 'Large'
sub.m_Info$ringtype[sub.m_Info$ringtype == 'n'] <- 'None'
sub.m_Info$ringtype[sub.m_Info$ringtype == 'p'] <- 'Pendant'
sub.m_Info$ringtype[sub.m_Info$ringtype == 's'] <- 'Sheathing'
sub.m_Info$ringtype[sub.m_Info$ringtype == 'z'] <- 'Zone'
sub.m_Info$ringtype <- as.factor(sub.m_Info$ringtype)
sub.m_Info$population <- as.character(sub.m_Info$population)
sub.m_Info$population[sub.m_Info$population == 'a'] <- 'Abundant'
sub.m_Info$population[sub.m_Info$population == 'c'] <- 'Clustered'
sub.m_Info$population[sub.m_Info$population == 'n'] <- 'Numerous'
sub.m_Info$population[sub.m_Info$population == 's'] <- 'Scattered'
sub.m_Info$population[sub.m_Info$population == 'v'] <- 'Several'
sub.m_Info$population[sub.m_Info$population == 'y'] <- 'Solitary'
sub.m_Info$population <- as.factor(sub.m_Info$population)
sub.m_Info$habitat <- as.character(sub.m_Info$habitat)
sub.m_Info$habitat[sub.m_Info$habitat == 'g'] <- 'Grasses'
sub.m_Info$habitat[sub.m_Info$habitat == 'l'] <- 'Leaves'
sub.m_Info$habitat[sub.m_Info$habitat == 'm'] <- 'Meadows'
sub.m_Info$habitat[sub.m_Info$habitat == 'p'] <- 'Paths'
sub.m_Info$habitat[sub.m_Info$habitat == 'u'] <- 'Urban'
sub.m_Info$habitat[sub.m_Info$habitat == 'w'] <- 'Waste'
sub.m_Info$habitat[sub.m_Info$habitat == 'd'] <- 'Woods'
sub.m_Info$habitat <- as.factor(sub.m_Info$habitat)
summary(sub.m_Info)
## class ringtype population habitat
## Edible :4208 Evanescent:2776 Abundant : 384 Grasses:2148
## Poisonous:3916 Flaring : 48 Clustered: 340 Leaves : 832
## Large :1296 Numerous : 400 Meadows: 292
## None : 36 Scattered:1248 Paths :1144
## Pendant :3968 Several :4040 Urban : 368
## Solitary :1712 Waste : 192
## Woods :3148