Skip to content

Instantly share code, notes, and snippets.

@grassa
Created July 19, 2010 13:45
Show Gist options
  • Save grassa/481422 to your computer and use it in GitHub Desktop.
Save grassa/481422 to your computer and use it in GitHub Desktop.
## read in our data
data<-read.table("binned.ele",head=T)
## how are our variables named?
names(data)
## attach them
attach(data)
## are the sample variances significantly different?
var.test(BEFORE,AFTER)
## they're not, so we can't use a t-test
## we use the wilcoxon's rank test
wilcox.test(BEFORE,AFTER)
## the means are highly significantly different
## let's look at the distribution of differences between "before" and "after" for all species
DIFF<-(AFTER-BEFORE)
## we'll output to a pdf
pdf("mean_alt_diff.pdf")
## plot the histogram
hist(DIFF,xlab="Difference in mean altitude (m)",ylab="Number of species",main="")
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment