fruitfly <- read.table("C:/Rexamples/fruitflydata.txt", header=T) View(fruitfly) summary(fruitfly) fruitfly$line2 <- fruitfly$line fruitfly$line2 <- sub("SS", "S", fruitfly$line2, ignore.case =FALSE, fixed=FALSE) fruitfly$line2 <- sub("RS", "S", fruitfly$line2, ignore.case =FALSE, fixed=FALSE) fruitfly attach(fruitfly) by(fecund, line, function(x) summary(x)) by(fecund, line, function(x) sd(x)) boxplot(fecund~line) by(fecund, line, function(x) stem(x)) qqnorm(fecund[line=='NS'], main="Normal Q-Q Plot, NS line") qqline(fecund[line=='NS']) shapiro.test(fecund[line=='NS']) qqnorm(fecund[line=='RS'], main="Normal Q-Q Plot, RS line") qqline(fecund[line=='RS']) shapiro.test(fecund[line=='RS']) qqnorm(fecund[line=='SS'], main="Normal Q-Q Plot, SS line") qqline(fecund[line=='SS']) shapiro.test(fecund[line=='SS']) fruitfly_RSSS <- subset(fruitfly, line != 'NS') t.test(fruitfly_RSSS$fecund~fruitfly_RSSS$line) t.test(fruitfly_RSSS$fecund~fruitfly_RSSS$line, var.equal=TRUE) by(fecund, line2, function(x) summary(x)) by(fecund, line2, function(x) sd(x)) boxplot(fecund~line2) by(fecund, line2, function(x) stem(x)) qqnorm(fecund[line2=='S'], main="Normal Q-Q Plot, S line") qqline(fecund[line2=='S']) shapiro.test(fecund[line2=='S']) t.test(fecund~line2) t.test(fecund~line2, var.equal=TRUE) --------------------- NOTE ------------------------ The first line above which reads the data from the file "fruitflydata.txt" assumes that this file is in the directory "C:/Rexamples". Obey this convention or modify the command. -------------------------- results ---------------------------------- The boxplots and normal probability plots (qqplots) 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. -------------------------------------------------------- > fruitfly <- read.table("C:/Rexamples/fruitflydata.txt", header=T) > View(fruitfly) > summary(fruitfly) line fecund NS:25 Min. :10.80 RS:25 1st Qu.:20.30 SS:25 Median :26.70 Mean :27.42 3rd Qu.:34.50 Max. :51.80 > fruitfly$line2 <- fruitfly$line > fruitfly$line2 <- sub("SS", "S", fruitfly$line2, ignore.case =FALSE, fixed=FALSE) > fruitfly$line2 <- sub("RS", "S", fruitfly$line2, ignore.case =FALSE, fixed=FALSE) > fruitfly line fecund line2 1 RS 12.8 S 2 RS 21.6 S 3 RS 14.8 S 4 RS 23.1 S 5 RS 34.6 S 6 RS 19.7 S 7 RS 22.6 S 8 RS 29.6 S 9 RS 16.4 S 10 RS 20.3 S 11 RS 29.3 S 12 RS 14.9 S 13 RS 27.3 S 14 RS 22.4 S 15 RS 27.5 S 16 RS 20.3 S 17 RS 38.7 S 18 RS 26.4 S 19 RS 23.7 S 20 RS 26.1 S 21 RS 29.5 S 22 RS 38.6 S 23 RS 44.4 S 24 RS 23.2 S 25 RS 23.6 S 26 SS 38.4 S 27 SS 32.9 S 28 SS 48.5 S 29 SS 20.9 S 30 SS 11.6 S 31 SS 22.3 S 32 SS 30.2 S 33 SS 33.4 S 34 SS 26.7 S 35 SS 39.0 S 36 SS 12.8 S 37 SS 14.6 S 38 SS 12.2 S 39 SS 23.1 S 40 SS 29.4 S 41 SS 16.0 S 42 SS 20.1 S 43 SS 23.3 S 44 SS 22.9 S 45 SS 22.5 S 46 SS 15.1 S 47 SS 31.0 S 48 SS 16.9 S 49 SS 16.1 S 50 SS 10.8 S 51 NS 35.4 NS 52 NS 27.4 NS 53 NS 19.3 NS 54 NS 41.8 NS 55 NS 20.3 NS 56 NS 37.6 NS 57 NS 36.9 NS 58 NS 37.3 NS 59 NS 28.2 NS 60 NS 23.4 NS 61 NS 33.7 NS 62 NS 29.2 NS 63 NS 41.7 NS 64 NS 22.6 NS 65 NS 40.4 NS 66 NS 34.4 NS 67 NS 30.4 NS 68 NS 14.9 NS 69 NS 51.8 NS 70 NS 33.8 NS 71 NS 37.9 NS 72 NS 29.5 NS 73 NS 42.4 NS 74 NS 36.6 NS 75 NS 47.4 NS > attach(fruitfly) > > by(fecund, line, function(x) summary(x)) line: NS Min. 1st Qu. Median Mean 3rd Qu. Max. 14.90 28.20 34.40 33.37 37.90 51.80 ----------------------------------------------- line: RS Min. 1st Qu. Median Mean 3rd Qu. Max. 12.80 20.30 23.60 25.26 29.30 44.40 ----------------------------------------------- line: SS Min. 1st Qu. Median Mean 3rd Qu. Max. 10.80 16.00 22.50 23.63 30.20 48.50 > by(fecund, line, function(x) sd(x)) line: NS [1] 8.942013 ----------------------------------------------- line: RS [1] 7.772391 ----------------------------------------------- line: SS [1] 9.768466 > boxplot(fecund~line) > the boxplots appear in the plot window of RStudio ***************** > by(fecund, line, function(x) stem(x)) The decimal point is 1 digit(s) to the right of the | 1 | 59 2 | 033789 3 | 00444577788 4 | 02227 5 | 2 The decimal point is 1 digit(s) to the right of the | 1 | 3556 2 | 000223334466789 3 | 00599 4 | 4 The decimal point is 1 digit(s) to the right of the | 1 | 122355667 2 | 012333379 3 | 013389 4 | 9 line: NS NULL ----------------------------------------------- line: RS NULL ----------------------------------------------- line: SS NULL > > > qqnorm(fecund[line=='NS'], main="Normal Q-Q Plot, NS line") > qqline(fecund[line=='NS']) > shapiro.test(fecund[line=='NS']) Shapiro-Wilk normality test data: fecund[line == "NS"] W = 0.9839, p-value = 0.9498 > the normal probability plot appears in the plot window of RStudio ***************** > > qqnorm(fecund[line=='RS'], main="Normal Q-Q Plot, RS line") > qqline(fecund[line=='RS']) > shapiro.test(fecund[line=='RS']) Shapiro-Wilk normality test data: fecund[line == "RS"] W = 0.9496, p-value = 0.245 > the normal probability plot appears in the plot window of RStudio ***************** > > qqnorm(fecund[line=='SS'], main="Normal Q-Q Plot, SS line") > qqline(fecund[line=='SS']) > shapiro.test(fecund[line=='SS']) Shapiro-Wilk normality test data: fecund[line == "SS"] W = 0.9396, p-value = 0.1446 > the normal probability plot appears in the plot window of RStudio ***************** > > > fruitfly_RSSS <- subset(fruitfly, line != 'NS') > t.test(fruitfly_RSSS$fecund~fruitfly_RSSS$line) Welch Two Sample t-test data: fruitfly_RSSS$fecund by fruitfly_RSSS$line t = 0.6521, df = 45.693, p-value = 0.5176 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -3.39843 6.65443 sample estimates: mean in group RS mean in group SS 25.256 23.628 > t.test(fruitfly_RSSS$fecund~fruitfly_RSSS$line, var.equal=TRUE) Two Sample t-test data: fruitfly_RSSS$fecund by fruitfly_RSSS$line t = 0.6521, df = 48, p-value = 0.5175 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -3.391875 6.647875 sample estimates: mean in group RS mean in group SS 25.256 23.628 > > > by(fecund, line2, function(x) summary(x)) line2: NS Min. 1st Qu. Median Mean 3rd Qu. Max. 14.90 28.20 34.40 33.37 37.90 51.80 ----------------------------------------------- line2: S Min. 1st Qu. Median Mean 3rd Qu. Max. 10.80 17.60 23.10 24.44 29.48 48.50 > by(fecund, line2, function(x) sd(x)) line2: NS [1] 8.942013 ----------------------------------------------- line2: S [1] 8.775106 > boxplot(fecund~line2) > the boxplots appear in the plot window of RStudio ***************** > by(fecund, line2, function(x) stem(x)) The decimal point is 1 digit(s) to the right of the | 1 | 59 2 | 033789 3 | 00444577788 4 | 02227 5 | 2 The decimal point is 1 digit(s) to the right of the | 1 | 12233 1 | 55556667 2 | 00001222333333344 2 | 6677899 3 | 000133 3 | 58999 4 | 4 4 | 9 line2: NS NULL ----------------------------------------------- line2: S NULL > qqnorm(fecund[line2=='S'], main="Normal Q-Q Plot, S line") > qqline(fecund[line2=='S']) > shapiro.test(fecund[line2=='S']) Shapiro-Wilk normality test data: fecund[line2 == "S"] W = 0.9562, p-value = 0.06168 > the normal probability plot appears in the plot window of RStudio ***************** > t.test(fecund~line2) Welch Two Sample t-test data: fecund by line2 t = 4.1024, df = 47.305, p-value = 0.00016 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 4.5516 13.3084 sample estimates: mean in group NS mean in group S 33.372 24.442 > t.test(fecund~line2, var.equal=TRUE) Two Sample t-test data: fecund by line2 t = 4.1286, df = 73, p-value = 9.587e-05 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 4.619188 13.240812 sample estimates: mean in group NS mean in group S 33.372 24.442 > >