cholest <- read.table("C:/Rexamples/cholest_data.txt", header=T) View(cholest) summary(cholest) attach(cholest) cholest by(level, group, function(x) summary(x)) by(level, group, function(x) sd(x)) by(level, group, function(x) var(x)) boxplot(level~group) by(level, group, function(x) stem(x)) --------------------- NOTE ------------------------ The first line above which reads the data from the file "cholest_data.txt" assumes that this file is in the directory "C:/Rexamples". Obey this convention of modify the command. -------------------------- results ---------------------------------- The boxplots requested in this program will appear in the plot window of RStudio. They can be saved as pdfs or images. I have not posted them here. These plots are somewhat crude since I did not specify titles, labels, or such. The remainder of this file is copied and pasted from the RStudio command window. --------------------------------------------------------------------- > cholest <- read.table("C:/Rexamples/cholest_data.txt", header=T) > View(cholest) > summary(cholest) level group Min. : 95.0 rural:49 1st Qu.:145.2 urban:45 Median :182.5 Mean :185.7 3rd Qu.:219.2 Max. :330.0 > attach(cholest) > cholest level group 1 95 rural 2 108 rural 3 108 rural 4 114 rural 5 115 rural 6 124 rural 7 129 rural 8 129 rural 9 131 rural 10 131 rural 11 135 rural 12 136 rural 13 136 rural 14 139 rural 15 140 rural 16 142 rural 17 142 rural 18 143 rural 19 143 rural 20 144 rural 21 144 rural 22 145 rural 23 146 rural 24 148 rural 25 152 rural 26 152 rural 27 155 rural 28 157 rural 29 158 rural 30 158 rural 31 162 rural 32 165 rural 33 166 rural 34 171 rural 35 172 rural 36 173 rural 37 174 rural 38 175 rural 39 180 rural 40 181 rural 41 189 rural 42 192 rural 43 194 rural 44 197 rural 45 204 rural 46 220 rural 47 223 rural 48 226 rural 49 231 rural 50 133 urban 51 134 urban 52 155 urban 53 170 urban 54 175 urban 55 179 urban 56 181 urban 57 184 urban 58 188 urban 59 189 urban 60 190 urban 61 196 urban 62 197 urban 63 199 urban 64 200 urban 65 200 urban 66 201 urban 67 201 urban 68 204 urban 69 205 urban 70 205 urban 71 205 urban 72 206 urban 73 214 urban 74 217 urban 75 222 urban 76 222 urban 77 227 urban 78 227 urban 79 228 urban 80 234 urban 81 234 urban 82 236 urban 83 239 urban 84 241 urban 85 242 urban 86 244 urban 87 249 urban 88 252 urban 89 273 urban 90 279 urban 91 284 urban 92 284 urban 93 284 urban 94 330 urban > by(level, group, function(x) summary(x)) group: rural Min. 1st Qu. Median Mean 3rd Qu. Max. 95 136 152 157 174 231 ----------------------------------------------- group: urban Min. 1st Qu. Median Mean 3rd Qu. Max. 133.0 196.0 206.0 216.9 239.0 330.0 > by(level, group, function(x) sd(x)) group: rural [1] 31.74868 ----------------------------------------------- group: urban [1] 39.92015 > by(level, group, function(x) var(x)) group: rural [1] 1007.979 ----------------------------------------------- group: urban [1] 1593.618 > boxplot(level~group) > by(level, group, function(x) stem(x)) The decimal point is 1 digit(s) to the right of the | 8 | 5 10 | 8845 12 | 499115669 14 | 0223344568225788 16 | 25612345 18 | 019247 20 | 4 22 | 0361 The decimal point is 1 digit(s) to the right of the | 12 | 34 14 | 5 16 | 059 18 | 14890679 20 | 00114555647 22 | 227784469 24 | 12492 26 | 39 28 | 444 30 | 32 | 0 group: rural NULL ----------------------------------------------- group: urban NULL > >