all214 <- read.table("C:/Rexamples/214all_data.txt", header=T) View(all214) summary(all214) attach(all214) all214 summary(sex) prop.table(table(sex)) plot(sex) by(sex, section, function(x) summary(x)) by(sex, section, function(x) prop.table(table(x))) by(sex, section, function(x) plot(x)) summary(class) prop.table(table(class)) plot(class) by(class, section, function(x) summary(x)) by(class, section, function(x) prop.table(table(x))) by(class, section, function(x) plot(x)) summary(height) sd(height) var(height) boxplot(height) stem(height) by(height, sex, function(x) summary(x)) by(height, sex, function(x) sd(x)) by(height, sex, function(x) var(x)) boxplot(height~sex) by(height, sex, function(x) stem(x)) summary(weight) sd(weight) var(weight) boxplot(weight) stem(weight) by(weight, sex, function(x) summary(x)) by(weight, sex, function(x) sd(x)) by(weight, sex, function(x) var(x)) boxplot(weight~sex) by(weight, sex, function(x) stem(x)) summary(siblings) sd(siblings) var(siblings) boxplot(siblings) stem(siblings) --------------------- NOTE ------------------------ The first line above which reads the data from the file "214all_data.txt" assumes that this file is in the directory "C:/Rexamples". Obey this convention or modify the command. -------------------------- results ---------------------------------- The bargraphs and 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. --------------------------------------------------------------------- > all214 <- read.table("C:/Rexamples/214all_data.txt", header=T) > View(all214) > summary(all214) line section class sex Min. : 1.0 Min. :1.000 a_fresh :27 female:51 1st Qu.:17.5 1st Qu.:1.000 b_soph :16 male :16 Median :34.0 Median :1.000 c_junior:16 Mean :34.0 Mean :1.463 d_senior: 8 3rd Qu.:50.5 3rd Qu.:2.000 Max. :67.0 Max. :2.000 age height weight Min. :18.00 Min. :59.00 Min. : 95.0 1st Qu.:18.00 1st Qu.:63.00 1st Qu.:116.5 Median :20.00 Median :66.00 Median :135.0 Mean :21.67 Mean :65.97 Mean :140.0 3rd Qu.:22.00 3rd Qu.:68.00 3rd Qu.:161.0 Max. :48.00 Max. :75.00 Max. :205.0 siblings Min. :0.000 1st Qu.:1.000 Median :2.000 Mean :2.269 3rd Qu.:3.000 Max. :7.000 > attach(all214) The following objects are masked from all214 (position 3): age, class, height, line, section, sex, siblings, weight > all214 line section class sex age height weight siblings 1 1 1 d_senior male 21 69 170 1 2 2 1 c_junior male 25 71 165 3 3 3 1 c_junior female 25 62 160 2 4 4 1 a_fresh male 18 72 162 1 5 5 1 c_junior female 22 63 170 1 6 6 1 a_fresh female 18 64 110 2 7 7 1 a_fresh female 18 60 103 1 8 8 1 a_fresh female 18 68 135 3 9 9 1 b_soph female 19 62 105 5 10 10 1 a_fresh male 18 74 190 2 11 11 1 b_soph female 20 70 150 1 12 12 1 d_senior female 21 61 116 1 13 13 1 a_fresh female 18 65 150 3 14 14 1 a_fresh female 19 64 140 4 15 15 1 a_fresh male 18 68 130 2 16 16 1 a_fresh female 18 63 110 2 17 17 1 b_soph female 21 62 125 1 18 18 1 a_fresh female 18 63 115 2 19 19 1 a_fresh female 19 64 135 3 20 20 1 a_fresh female 18 69 155 1 21 21 1 b_soph female 20 65 110 2 22 22 1 b_soph female 19 68 140 1 23 23 1 a_fresh female 47 66 110 1 24 24 1 b_soph female 20 70 145 2 25 25 1 a_fresh female 20 61 140 5 26 26 1 a_fresh female 18 63 180 0 27 27 1 c_junior male 22 70 175 2 28 28 1 a_fresh female 18 63 120 1 29 29 1 d_senior female 22 68 170 2 30 30 1 a_fresh female 18 66 125 3 31 31 1 c_junior male 22 75 205 2 32 32 1 a_fresh female 18 67 110 1 33 33 1 d_senior male 22 68 135 1 34 34 1 d_senior female 22 64 185 2 35 35 1 a_fresh female 41 61 96 1 36 36 1 c_junior female 22 59 95 5 37 37 2 c_junior female 20 66 110 1 38 38 2 c_junior male 20 72 180 1 39 39 2 c_junior female 21 66 120 1 40 40 2 b_soph female 21 61 105 3 41 41 2 a_fresh female 18 68 134 7 42 42 2 a_fresh female 28 66 130 4 43 43 2 b_soph female 26 64 135 4 44 44 2 b_soph female 19 64 117 1 45 45 2 a_fresh female 20 66 140 4 46 46 2 c_junior female 20 64 130 1 47 47 2 d_senior female 48 66 140 3 48 48 2 c_junior female 22 67 115 2 49 49 2 b_soph female 19 66 170 2 50 50 2 a_fresh male 18 66 190 3 51 51 2 b_soph female 21 67 135 4 52 52 2 a_fresh female 20 68 140 2 53 53 2 b_soph female 19 62 115 2 54 54 2 b_soph female 20 60 110 2 55 55 2 a_fresh male 18 72 185 3 56 56 2 d_senior male 23 72 190 2 57 57 2 d_senior male 24 69 170 4 58 58 2 c_junior male 21 72 140 3 59 59 2 c_junior female 20 65 112 2 60 60 2 c_junior female 21 62 130 1 61 61 2 a_fresh female 18 64 120 1 62 62 2 b_soph female 25 66 145 2 63 63 2 c_junior male 19 65 156 6 64 64 2 a_fresh female 18 67 125 0 65 65 2 c_junior female 44 66 165 4 66 66 2 b_soph male 19 71 155 3 67 67 2 b_soph female 19 62 133 2 > summary(sex) female male 51 16 > prop.table(table(sex)) sex female male 0.761194 0.238806 > plot(sex) > by(sex, section, function(x) summary(x)) section: 1 female male 28 8 ----------------------------------------------- section: 2 female male 23 8 > by(sex, section, function(x) prop.table(table(x))) section: 1 x female male 0.7777778 0.2222222 ----------------------------------------------- section: 2 x female male 0.7419355 0.2580645 > by(sex, section, function(x) plot(x)) section: 1 [,1] [1,] 0.7 [2,] 1.9 ----------------------------------------------- section: 2 [,1] [1,] 0.7 [2,] 1.9 > summary(class) a_fresh b_soph c_junior d_senior 27 16 16 8 > prop.table(table(class)) class a_fresh b_soph c_junior d_senior 0.4029851 0.2388060 0.2388060 0.1194030 > plot(class) > by(class, section, function(x) summary(x)) section: 1 a_fresh b_soph c_junior d_senior 19 6 6 5 ----------------------------------------------- section: 2 a_fresh b_soph c_junior d_senior 8 10 10 3 > by(class, section, function(x) prop.table(table(x))) section: 1 x a_fresh b_soph c_junior d_senior 0.5277778 0.1666667 0.1666667 0.1388889 ----------------------------------------------- section: 2 x a_fresh b_soph c_junior d_senior 0.25806452 0.32258065 0.32258065 0.09677419 > by(class, section, function(x) plot(x)) section: 1 [,1] [1,] 0.7 [2,] 1.9 [3,] 3.1 [4,] 4.3 ----------------------------------------------- section: 2 [,1] [1,] 0.7 [2,] 1.9 [3,] 3.1 [4,] 4.3 > summary(height) Min. 1st Qu. Median Mean 3rd Qu. Max. 59.00 63.00 66.00 65.97 68.00 75.00 > sd(height) [1] 3.65136 > var(height) [1] 13.33243 > boxplot(height) > stem(height) The decimal point is at the | 58 | 0 60 | 000000 62 | 00000000000 64 | 000000000000 66 | 000000000000000 68 | 0000000000 70 | 00000 72 | 00000 74 | 00 > by(height, sex, function(x) summary(x)) sex: female Min. 1st Qu. Median Mean 3rd Qu. Max. 59.00 62.50 64.00 64.59 66.00 70.00 ----------------------------------------------- sex: male Min. 1st Qu. Median Mean 3rd Qu. Max. 65.00 68.75 71.00 70.38 72.00 75.00 > by(height, sex, function(x) sd(x)) sex: female [1] 2.684597 ----------------------------------------------- sex: male [1] 2.729469 > by(height, sex, function(x) var(x)) sex: female [1] 7.207059 ----------------------------------------------- sex: male [1] 7.45 > boxplot(height~sex) > by(height, sex, function(x) stem(x)) The decimal point is at the | 58 | 0 60 | 000000 62 | 00000000000 64 | 00000000000 66 | 00000000000000 68 | 000000 70 | 00 The decimal point is 1 digit(s) to the right of the | 6 | 568899 7 | 011222224 7 | 5 sex: female NULL ----------------------------------------------- sex: male NULL > summary(weight) Min. 1st Qu. Median Mean 3rd Qu. Max. 95.0 116.5 135.0 140.0 161.0 205.0 > sd(weight) [1] 27.0014 > var(weight) [1] 729.0755 > boxplot(weight) > stem(weight) The decimal point is 1 digit(s) to the right of the | 8 | 56 10 | 3550000000255567 12 | 00055500003455555 14 | 00000005500556 16 | 0255000005 18 | 0055000 20 | 5 > by(weight, sex, function(x) summary(x)) sex: female Min. 1st Qu. Median Mean 3rd Qu. Max. 95.0 113.5 130.0 131.0 140.0 185.0 ----------------------------------------------- sex: male Min. 1st Qu. Median Mean 3rd Qu. Max. 130.0 155.8 170.0 168.6 186.2 205.0 > by(weight, sex, function(x) sd(x)) sex: female [1] 21.8623 ----------------------------------------------- sex: male [1] 21.5712 > by(weight, sex, function(x) var(x)) sex: female [1] 477.96 ----------------------------------------------- sex: male [1] 465.3167 > boxplot(weight~sex) > by(weight, sex, function(x) stem(x)) The decimal point is 1 digit(s) to the right of the | 9 | 56 10 | 355 11 | 0000000255567 12 | 000555 13 | 000345555 14 | 00000055 15 | 005 16 | 05 17 | 000 18 | 05 The decimal point is 1 digit(s) to the right of the | 12 | 05 14 | 056 16 | 25005 18 | 05000 20 | 5 sex: female NULL ----------------------------------------------- sex: male NULL > summary(siblings) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000 1.000 2.000 2.269 3.000 7.000 > sd(siblings) [1] 1.409729 > var(siblings) [1] 1.987336 > boxplot(siblings) > stem(siblings) The decimal point is at the | 0 | 00 1 | 000000000000000000000 2 | 000000000000000000000 3 | 00000000000 4 | 0000000 5 | 000 6 | 0 7 | 0 > >