ratcortex <- read.table("C:/Rexamples/ratcortexdata.txt", header=T) View(ratcortex) summary(ratcortex) attach(ratcortex) diff <- stim - nostim # summary for all 5 experiments by(diff, exper, function(x) summary(x)) by(diff, exper, function(x) sd(x)) boxplot(diff~exper) by(diff, exper, function(x) stem(x)) # analysis for experiment 1 summary(diff[exper==1]) boxplot(diff[exper==1]) stem(diff[exper==1]) qqnorm(diff[exper==1], main="Normal Q-Q Plot, exper=1") qqline(diff[exper==1]) shapiro.test(diff[exper==1]) t.test(diff[exper==1]) # analysis for experiment 2 summary(diff[exper==2]) boxplot(diff[exper==2]) stem(diff[exper==2]) qqnorm(diff[exper==2], main="Normal Q-Q Plot, exper=2") qqline(diff[exper==2]) shapiro.test(diff[exper==2]) t.test(diff[exper==2]) # analysis for experiment 3 summary(diff[exper==3]) boxplot(diff[exper==3]) stem(diff[exper==3]) qqnorm(diff[exper==3], main="Normal Q-Q Plot, exper=3") qqline(diff[exper==3]) shapiro.test(diff[exper==3]) t.test(diff[exper==3]) # analysis for experiment 4 summary(diff[exper==4]) boxplot(diff[exper==4]) stem(diff[exper==4]) qqnorm(diff[exper==4], main="Normal Q-Q Plot, exper=4") qqline(diff[exper==4]) shapiro.test(diff[exper==4]) t.test(diff[exper==4]) # analysis for experiment 5 summary(diff[exper==5]) boxplot(diff[exper==5]) stem(diff[exper==5]) qqnorm(diff[exper==5], main="Normal Q-Q Plot, exper=5") qqline(diff[exper==5]) shapiro.test(diff[exper==5]) t.test(diff[exper==5]) --------------------- NOTE ------------------------ The first line above which reads the data from the file "ratcortexdata.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 (qqplot) 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. -------------------------------------------------------- > ratcortex <- read.table("C:/Rexamples/ratcortexdata.txt", header=T) > View(ratcortex) > summary(ratcortex) exper stim nostim Min. :1.000 Min. :624.0 Min. :578.0 1st Qu.:2.000 1st Qu.:655.5 1st Qu.:633.5 Median :3.000 Median :680.0 Median :650.0 Mean :3.034 Mean :683.4 Mean :647.2 3rd Qu.:4.000 3rd Qu.:707.5 3rd Qu.:668.5 Max. :5.000 Max. :751.0 Max. :705.0 > attach(ratcortex) > diff <- stim - nostim > # summary for all 5 experiments > by(diff, exper, function(x) summary(x)) exper: 1 Min. 1st Qu. Median Mean 3rd Qu. Max. -2.00 9.00 17.00 26.73 32.50 89.00 ----------------------------------------------- exper: 2 Min. 1st Qu. Median Mean 3rd Qu. Max. -7.00 31.75 43.00 44.67 60.00 94.00 ----------------------------------------------- exper: 3 Min. 1st Qu. Median Mean 3rd Qu. Max. -17.0 19.5 31.5 31.0 43.0 76.0 ----------------------------------------------- exper: 4 Min. 1st Qu. Median Mean 3rd Qu. Max. -10.00 15.25 32.00 40.67 46.75 150.00 ----------------------------------------------- exper: 5 Min. 1st Qu. Median Mean 3rd Qu. Max. -12.00 16.00 46.00 37.33 57.00 75.00 > by(diff, exper, function(x) sd(x)) exper: 1 [1] 27.32797 ----------------------------------------------- exper: 2 [1] 30.86726 ----------------------------------------------- exper: 3 [1] 25.31618 ----------------------------------------------- exper: 4 [1] 43.84961 ----------------------------------------------- exper: 5 [1] 28.46476 > boxplot(diff~exper) > by(diff, exper, function(x) stem(x)) The decimal point is 1 digit(s) to the right of the | -0 | 2 0 | 67167 2 | 123 4 | 6 | 4 8 | 9 The decimal point is 2 digit(s) to the right of the | -0 | 1 0 | 03344 0 | 556799 The decimal point is 1 digit(s) to the right of the | -0 | 7 0 | 32 2 | 239489 4 | 58 6 | 6 The decimal point is 2 digit(s) to the right of the | -0 | 10 0 | 1223444 0 | 69 1 | 1 | 5 The decimal point is 1 digit(s) to the right of the | -0 | 21 0 | 1 2 | 1 4 | 05706 6 | 065 exper: 1 NULL ----------------------------------------------- exper: 2 NULL ----------------------------------------------- exper: 3 NULL ----------------------------------------------- exper: 4 NULL ----------------------------------------------- exper: 5 NULL > # analysis for experiment 1 > summary(diff[exper==1]) Min. 1st Qu. Median Mean 3rd Qu. Max. -2.00 9.00 17.00 26.73 32.50 89.00 > boxplot(diff[exper==1]) > stem(diff[exper==1]) The decimal point is 1 digit(s) to the right of the | -0 | 2 0 | 67167 2 | 123 4 | 6 | 4 8 | 9 > qqnorm(diff[exper==1], main="Normal Q-Q Plot, exper=1") > qqline(diff[exper==1]) > shapiro.test(diff[exper==1]) Shapiro-Wilk normality test data: diff[exper == 1] W = 0.8447, p-value = 0.03635 > t.test(diff[exper==1]) One Sample t-test data: diff[exper == 1] t = 3.2437, df = 10, p-value = 0.008814 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 8.36809 45.08646 sample estimates: mean of x 26.72727 > # analysis for experiment 2 > summary(diff[exper==2]) Min. 1st Qu. Median Mean 3rd Qu. Max. -7.00 31.75 43.00 44.67 60.00 94.00 > boxplot(diff[exper==2]) > stem(diff[exper==2]) The decimal point is 2 digit(s) to the right of the | -0 | 1 0 | 03344 0 | 556799 > qqnorm(diff[exper==2], main="Normal Q-Q Plot, exper=2") > qqline(diff[exper==2]) > shapiro.test(diff[exper==2]) Shapiro-Wilk normality test data: diff[exper == 2] W = 0.9647, p-value = 0.8486 > t.test(diff[exper==2]) One Sample t-test data: diff[exper == 2] t = 5.0128, df = 11, p-value = 0.0003945 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 25.05454 64.27879 sample estimates: mean of x 44.66667 > # analysis for experiment 3 > summary(diff[exper==3]) Min. 1st Qu. Median Mean 3rd Qu. Max. -17.0 19.5 31.5 31.0 43.0 76.0 > boxplot(diff[exper==3]) > stem(diff[exper==3]) The decimal point is 1 digit(s) to the right of the | -0 | 7 0 | 32 2 | 239489 4 | 58 6 | 6 > qqnorm(diff[exper==3], main="Normal Q-Q Plot, exper=3") > qqline(diff[exper==3]) > shapiro.test(diff[exper==3]) Shapiro-Wilk normality test data: diff[exper == 3] W = 0.9896, p-value = 0.9997 > t.test(diff[exper==3]) One Sample t-test data: diff[exper == 3] t = 4.2418, df = 11, p-value = 0.001385 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 14.91487 47.08513 sample estimates: mean of x 31 > # analysis for experiment 4 > summary(diff[exper==4]) Min. 1st Qu. Median Mean 3rd Qu. Max. -10.00 15.25 32.00 40.67 46.75 150.00 > boxplot(diff[exper==4]) > stem(diff[exper==4]) The decimal point is 2 digit(s) to the right of the | -0 | 10 0 | 1223444 0 | 69 1 | 1 | 5 > qqnorm(diff[exper==4], main="Normal Q-Q Plot, exper=4") > qqline(diff[exper==4]) > shapiro.test(diff[exper==4]) Shapiro-Wilk normality test data: diff[exper == 4] W = 0.8686, p-value = 0.06265 > t.test(diff[exper==4]) One Sample t-test data: diff[exper == 4] t = 3.2127, df = 11, p-value = 0.008266 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 12.80596 68.52738 sample estimates: mean of x 40.66667 > # analysis for experiment 5 > summary(diff[exper==5]) Min. 1st Qu. Median Mean 3rd Qu. Max. -12.00 16.00 46.00 37.33 57.00 75.00 > boxplot(diff[exper==5]) > stem(diff[exper==5]) The decimal point is 1 digit(s) to the right of the | -0 | 21 0 | 1 2 | 1 4 | 05706 6 | 065 > qqnorm(diff[exper==5], main="Normal Q-Q Plot, exper=5") > qqline(diff[exper==5]) > shapiro.test(diff[exper==5]) Shapiro-Wilk normality test data: diff[exper == 5] W = 0.9147, p-value = 0.2452 > t.test(diff[exper==5]) One Sample t-test data: diff[exper == 5] t = 4.5434, df = 11, p-value = 0.0008392 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 19.24769 55.41898 sample estimates: mean of x 37.33333 > >