Load mushrooms data from the site, rename columns and change values for cap color, odor, class and habitat
dataFile <-'https://archive.ics.uci.edu/ml/machine-learning-databases/mushroom/agaricus-lepiota.data'
mushrooms <-read.csv(file=dataFile, header=FALSE, sep=",", )
names(mushrooms)<-col_names
levels(mushrooms$`cap-color`)<-cap_colors
levels(mushrooms$habitat)<-habitats
levels(mushrooms$odor)<-odors
levels(mushrooms$class)<-class
dim(mushrooms)
## [1] 8124 23
##Coulmn Names
names(mushrooms)
## [1] "class" "cap-shape"
## [3] "cap-surface" "cap-color"
## [5] "bruises" "odor"
## [7] "gill-attachment" "gill-spacing"
## [9] "gill-size" "gill-color"
## [11] "stalk-shape" "stalk-root"
## [13] "stalk-surface-above-ring" "stalk-surface-below-ring"
## [15] "stalk-color-above-ring" "stalk-color-below-ring"
## [17] "veil-type" "veil-color"
## [19] "ring-number" "ring-type"
## [21] "spore-print-color" "population"
## [23] "habitat"
## Summary for cap Color, Odor, Class and Habitat
mushroom_summary <- data.frame(mushrooms$class, mushrooms$`cap-color`, mushrooms$odor, mushrooms$habitat)
summary.data.frame(mushroom_summary)
## mushrooms.class mushrooms..cap.color. mushrooms.odor mushrooms.habitat
## Edible :4208 green :2284 musty :3528 grasses:3148
## Poisonous:3916 gray :1840 creosote:2160 leaves :2148
## cinnamon:1500 pungent : 576 meadows: 832
## yellow :1072 spicy : 576 paths : 292
## white :1040 almond : 400 urban :1144
## brown : 168 fishy : 400 waste : 368
## (Other) : 220 (Other) : 484 woods : 192
##
## brown buff cinnamon gray green pink purple red
## 168 44 1500 1840 2284 144 16 16
## white yellow
## 1040 1072
##
## almond anise creosote fishy foul musty none pungent
## 400 192 2160 400 36 3528 256 576
## spicy
## 576
##
## Edible Poisonous
## 4208 3916
##
## almond anise creosote fishy foul musty none pungent spicy
## Edible 400 0 0 400 0 3408 0 0 0
## Poisonous 0 192 2160 0 36 120 256 576 576
##
## grasses leaves meadows paths urban waste woods
## Edible 1880 1408 240 256 136 96 192
## Poisonous 1268 740 592 36 1008 272 0
##
## brown buff cinnamon gray green pink purple red white yellow
## Edible 48 32 624 1032 1264 56 16 16 720 400
## Poisonous 120 12 876 808 1020 88 0 0 320 672