## Lab Exercise 2 for R: Descriptive Statistics

### Exercise 1:

• Download the file "TreesU.txt". Save the content of the file as a TEXT file and you will be able to view and edit it with any text editor, such as jEdit. It is originally a Unix file containing data on trees mapped with GPS. Data entries are arranged in column format, separated by horizontal tabs with variable names in the first row. Consult the file "TreesU_Ins.txt" for information about what variables are present and where they are and process the file (if needed).
• Or import the file into R directly from the webserver
 > trees <- read.table("http://caspar.bgsu.edu/~courses/stats/Labs/Datasets/TreesU.txt", sep="\t", header=T, na.strings = ".") > write.table(trees) > names(trees)

### Exercise 2:

• Obtain descriptive statistics for the diameter of tree trunks
 > xtabs(~Name, data = trees) > summary(trees\$Diam) > mean(trees\$Diam, na.rm=TRUE) > install.packages("pastecs"); library(pastecs) > options(digits=4) > stat.desc(trees) > install.packages("psych"); library(psych) > describe(trees) > install.packages("Hmisc"); library(Hmisc) > describe(trees) This reports descriptive stats for tree species subgroups > describeBy(trees\$Diam, group = trees\$Name)

### Exercise 3:

• Obtain descriptive plots for the diameter of tree trunks, including a Q-Q plot with added predicted line
 > qqnorm(trees\$Diam) > qqline(trees\$Diam,col="red")