# Some useful commands for the project ################################ # Save the data set bed.txt in a directory, say, your A drive # Open R # Do ``change directory'' in R to A drive. This is Important!!! # (To ``change directory'', click on File, you will see the change # directory button. # Input lowbwt data bed <- read.table("bed.txt",header=T, sep="\t",quote="", skip=0, row.names=NULL) ####################### bed80 <- bed[[1]] bed86 <- bed[[2]] #### Boxplots boxplot(bed80, bed86) #### Boxplots: putting on the lables boxplot(bed80, bed86, axes=F) box() axis(side=2, at=3:7) axis(side=1, at=1:2, labels=c("bed80", "bed86")) title(main="Boxplots of bed data in 1980 and 1986") #### Histograms par(mfrow=c(2,1)) hist(bed80, probability=T) hist(bed86, probability=T) ### Scatter plot plot(bed80, bed86) ### paried t-test t.test(bed80-bed86) ### two-sample t-test: compare bed80 and bed86 t.test(bed80, bed86) ### two sample t-test: compare the first 24 states ### and the remaining 27 states bed86.1 <- bed86[1:24] bed86.2 <- bed86[25:51] t.test(bed86.1, bed86.2)