The “cane.csv” file looks at data from an experiment looking at the disease risk of different varieties of sugar cane and how different treatments could impact the levels of disease. The file contains several columns of data:
“nStems” = total number of stems “diseaseStems” = total number of stems with disease “variety” = the type of sugar cane “block” = treatment
NOTE: for each prompt, I need to see code in order to give you credit! NOTE: you can perform all of these tasks in one code chunk or many code chunks, this is up to you
sugar <- read.csv('cane.csv',sep=',', header=T)
nrow(sugar)
## [1] 180
str(sugar)
## 'data.frame': 180 obs. of 4 variables:
## $ nStems : int 87 119 94 95 134 92 118 70 128 85 ...
## $ diseaseStems: int 76 8 74 11 0 0 11 32 33 14 ...
## $ variety : int 1 2 3 4 5 6 7 8 9 10 ...
## $ block : chr "A" "A" "A" "A" ...
mean(sugar$diseaseStems)
## [1] 20.25556
tapply(sugar$diseaseStems, sugar$block, mean)
## A B C D
## 18.57778 25.48889 17.44444 19.51111
sugar$variety <- factor(sugar$variety)
aggregate(sugar$diseaseStems,
by = list(sugar$block, sugar$variety), mean)
## Group.1 Group.2 x
## 1 A 1 76
## 2 B 1 70
## 3 C 1 54
## 4 D 1 39
## 5 A 2 8
## 6 B 2 21
## 7 C 2 10
## 8 D 2 26
## 9 A 3 74
## 10 B 3 95
## 11 C 3 44
## 12 D 3 38
## 13 A 4 11
## 14 B 4 21
## 15 C 4 15
## 16 D 4 41
## 17 A 5 0
## 18 B 5 6
## 19 C 5 3
## 20 D 5 5
## 21 A 6 0
## 22 B 6 63
## 23 C 6 21
## 24 D 6 47
## 25 A 7 11
## 26 B 7 7
## 27 C 7 8
## 28 D 7 15
## 29 A 8 32
## 30 B 8 22
## 31 C 8 28
## 32 D 8 18
## 33 A 9 33
## 34 B 9 77
## 35 C 9 11
## 36 D 9 11
## 37 A 10 14
## 38 B 10 12
## 39 C 10 13
## 40 D 10 28
## 41 A 11 3
## 42 B 11 0
## 43 C 11 0
## 44 D 11 0
## 45 A 12 3
## 46 B 12 26
## 47 C 12 3
## 48 D 12 39
## 49 A 13 28
## 50 B 13 50
## 51 C 13 36
## 52 D 13 13
## 53 A 14 63
## 54 B 14 105
## 55 C 14 59
## 56 D 14 23
## 57 A 15 3
## 58 B 15 18
## 59 C 15 5
## 60 D 15 1
## 61 A 16 16
## 62 B 16 32
## 63 C 16 4
## 64 D 16 69
## 65 A 17 11
## 66 B 17 9
## 67 C 17 57
## 68 D 17 24
## 69 A 18 2
## 70 B 18 0
## 71 C 18 0
## 72 D 18 1
## 73 A 19 8
## 74 B 19 36
## 75 C 19 22
## 76 D 19 30
## 77 A 20 62
## 78 B 20 9
## 79 C 20 92
## 80 D 20 23
## 81 A 21 14
## 82 B 21 17
## 83 C 21 21
## 84 D 21 15
## 85 A 22 34
## 86 B 22 110
## 87 C 22 57
## 88 D 22 131
## 89 A 23 0
## 90 B 23 0
## 91 C 23 0
## 92 D 23 4
## 93 A 24 13
## 94 B 24 14
## 95 C 24 24
## 96 D 24 2
## 97 A 25 7
## 98 B 25 7
## 99 C 25 0
## 100 D 25 3
## 101 A 26 12
## 102 B 26 22
## 103 C 26 8
## 104 D 26 13
## 105 A 27 0
## 106 B 27 8
## 107 C 27 1
## 108 D 27 3
## 109 A 28 22
## 110 B 28 7
## 111 C 28 6
## 112 D 28 7
## 113 A 29 5
## 114 B 29 0
## 115 C 29 4
## 116 D 29 3
## 117 A 30 17
## 118 B 30 13
## 119 C 30 6
## 120 D 30 13
## 121 A 31 0
## 122 B 31 1
## 123 C 31 0
## 124 D 31 0
## 125 A 32 15
## 126 B 32 11
## 127 C 32 7
## 128 D 32 6
## 129 A 33 20
## 130 B 33 18
## 131 C 33 18
## 132 D 33 2
## 133 A 34 27
## 134 B 34 25
## 135 C 34 10
## 136 D 34 10
## 137 A 35 0
## 138 B 35 0
## 139 C 35 8
## 140 D 35 0
## 141 A 36 0
## 142 B 36 10
## 143 C 36 2
## 144 D 36 2
## 145 A 37 6
## 146 B 37 43
## 147 C 37 24
## 148 D 37 11
## 149 A 38 25
## 150 B 38 6
## 151 C 38 22
## 152 D 38 36
## 153 A 39 2
## 154 B 39 17
## 155 C 39 10
## 156 D 39 16
## 157 A 40 112
## 158 B 40 48
## 159 C 40 8
## 160 D 40 63
## 161 A 41 9
## 162 B 41 0
## 163 C 41 0
## 164 D 41 2
## 165 A 42 10
## 166 B 42 16
## 167 C 42 16
## 168 D 42 12
## 169 A 43 0
## 170 B 43 11
## 171 C 43 6
## 172 D 43 0
## 173 A 44 1
## 174 B 44 0
## 175 C 44 0
## 176 D 44 9
## 177 A 45 27
## 178 B 45 64
## 179 C 45 42
## 180 D 45 24
hist(sugar$nStems,
col = "orange",
main = "Stem Distribution")
Does the histogram of “nStems” appear to be normally distributed? (2 pts) The histogram is not normally distrubuted. This is because the bell curve is more saturated towards the right side, making it right skewed.
Create a boxplot for “diseaseStems” by “block” - create the plot so that each block has a different color box (6 pts)
boxplot(diseaseStems ~ block,
data = sugar,
col = c('orange','pink','red', "yellow"),
main = "Disease Stems by Block")
It looks like the block does have an influence on the number of disease stems, but not by much. It looks like Block B has the highest median and block C has the lowest median. Though there is not a large difference, having a very minimal influence on the number of disease stems.
BONUS: 5 pts total (3 for A, 2 for B) A. Create a new column for your dataset that creates the proportion or percentage of diseased stems for each plot
sugar$PropDiseased <- sugar$diseaseStems / sugar$nStems
B. Create a boxplot for the new column by “block”
boxplot(PropDiseased ~ block,
data = sugar,
col= c('orange', 'pink', 'red', 'yellow'),
main= "Proportion Diseased by Block")