# PMean: Resources for a workshop in R

## 2014/01/15

I’m helping to teach a beginner’s workshop on R. Here are some resources that we will get from the web, but if you can download these files to your computer ahead of time, that would be great.

Here are the files for the latest R version (3.0.2 as of the writing of this blog entry):

Here are the files for R Studio (what is R Studio?)

Here are the files for R Commander (what is R Commander?)

I’ll be using a data set on childhood respiratory diseases (read documentation for this file)

Here are the R commands and the associated output.

For your convenience, I am also including the R commands file below.

mean(crdAge)

# ways.

mean(crdAge,na.rm=TRUE)

# Use the table function to get counts for categorical data.

sd(crdAge) range(crdAge) quantile(crdAge) quantile(crdAge,probs=c(0.1,0.9)) summary(crdAge) table(crdSex)

# values in the table function with the useNA argument.

table(crdSex,useNA="always”)

# and re-use it.

age.mn <- mean(crdAge) age.sd <- sd(crdAge) ti <- paste(“The mean age is”,age.mn,“+/-",age.sd) hist(crdAge,main=ti)

# can then use it in several different ways.

lm.mod1 <- lm(FEV~Height,data=crd)

print(lm.mod1)

summary(lm.mod1)

anova(lm.mod1)

names(lm.mod1)

# the coefficients of the regression equation for later re-use.

co.mod1 <- lm.mod1coefficients b0 <- co.mod1 b1 <- co.mod1 r0 <- round(b0,1) r1 <- round(b1,2)

plot(crdHeight,crd\$FEV)

# abline draws a reference line with a given intercept and slope.

abline(a=b0,b=b1)

# you can also insert the equation into the title of the graph.

ti <- paste(“FEV =”,r0,“+”,r1,"* Height”) title(ti)

# end of file

Here are the two graphs produced by this output.  