setwd("C:/Users/Elizabeth Housworth/Desktop")
data <- read.table(file='HW01.txt', header=TRUE)
data
help(t.test)to read about the t.test function in R.
t.test(data[,2] ~ data[,1], data)data[,2] is the second column of data and data[,1] is the first column and the formula tells R to break up the data by the factor in the first column.
t.test(data[,2] ~ data[,1], data, alternative="greater")or
t.test(data[,2] ~ data[,1], data, alternative="less")Which one gives you the test and confidence interval you want? You can figure out the order R puts the factors in by typing
as.factor(data[,1])
treatment <- subset(data[,2], data[,1]=="Treated")and
control <-subset(data[,2], data[,1]=="Control")From this you can do things like find the means and standard deviations by typing things like
mean(treatment) sd(treatment)
boxplot(data[,2]~data[,1], data)To play with the graph, look at the help page for the boxplot by typing
help(boxplot)You can play with little things like changing the labels using "names" by typing
boxplot(data[,2]~data[,1], data, names=c("Control", "Treatment"))You can add titles after the fact by just typing
title(main="Effect of Activites on Reading Outcomes", sub="Treatment versus Control")Read about all of the things you can change by reading the help pages:
help(boxplot) help(bxp) help(par)Try to change the color of something - like the boxes or the labels.
Treatment Response Treated 24 Treated 43 Treated 58 Treated 71 Treated 43 Treated 49 Treated 61 Treated 44 Treated 67 Treated 49 Treated 53 Treated 56 Treated 59 Treated 52 Treated 62 Treated 54 Treated 57 Treated 33 Treated 46 Treated 43 Treated 57 Control 42 Control 43 Control 55 Control 26 Control 62 Control 37 Control 33 Control 41 Control 19 Control 54 Control 20 Control 85 Control 46 Control 10 Control 17 Control 60 Control 53 Control 42 Control 37 Control 42 Control 55 Control 28 Control 48