> Tb3dot1<-Read.Table( E:/Teach/Www/Subpages/Csuteach/St3502/Ott6ed-Data/Ott-6Ed

Total Page:16

File Type:pdf, Size:1020Kb

> Tb3dot1<-Read.Table( E:/Teach/Www/Subpages/Csuteach/St3502/Ott6ed-Data/Ott-6Ed

Example One

# Table 3.1

> tb3dot1<-read.table("E:/teach/www/SubPages/CSUteach/st3502/Ott6ed-data/Ott- 6ed_data_txt/RS/ch3resarchstudy.txt",na.strings=".",header=T) > colnames(tb3dot1)[5]<-"Minority_pcnt" > colnames(tb3dot1)[6]<-"Poverty_pcnt" > third.math<-tb3dot1$Math[1:22] > third.reading<-tb3dot1$Reading[1:22] > cor(third.math, third.reading)

# drawing polts

> plot(third.math,third.reading,main="Math vs. Reading for 3rd Grad") > stem(third.math) > stripchart(third.math, method="stack",pch=19, main="3rd Grade Math Score") > boxplot(tb3dot1$Math) > boxplot(tb3dot1$Math~tb3dot1$Grade) > boxplot(tb3dot1$Math~tb3dot1$Grade, main="Math vs. Grade")

Example Two

# generate data

> x<-rnorm(17) > y<-rbinom(17,10,.5) > time<-2000:2016 > sex<-c(rep("M",8),rep("F",9)) > group<-c(rep(c("A","B","C"),5),"A","B")

# drawing plots

> plot(time,y,type="l", main="time series plot") > plot(x,y,main="scatter plot") > cor(x,y) > boxplot(x~sex, main="side-by-side boxplot")

> barplot(table(sex), main="bar chart") > pie(table(sex), main="pie chart")

> counts<-table(group,sex) > barplot(counts,xlab="Sex",ylab="Frequency",ylim=c(0,15),legend=rownames(count s),main="Stacked bar chart")

# numerical summary

> summary(x) > quantile(x,.90) > IQR(x) > sd(x)

Recommended publications