comparison of the different sites

## code for calculating site characteristics
## first read in all data:

library(plyr)
library(reshape2)
library(ggplot2)
source("../Rscripts/all_sites_parameters.R")
opts_chunk$set(warning=FALSE,message=FALSE,echo=FALSE, dev="png")
sites <- c("Cardoso","Colombia","CostaRica","FrenchGuiana","Macae","Argentina","PuertoRico")

all_schedules <- lapply(sites,scheduleread)
names(x=all_schedules) <- sites

## standardize names
all_schedules_renamed <- lapply(all_schedules,function(df){
  names(df)[1:4] <- c("trt.name","mu","k","temporal.block")
  df
  })

allsites <- ldply(.data=all_schedules_renamed,.fun=melt,id.vars=c("trt.name","mu","k","temporal.block"))
names(allsites)[names(allsites)==".id"] <- "site"

By graphing the control (mu1k1) treatments, we can compare the amount (mu) and the variation in rainfall (k) across all sites:

#ggplot(allsites,aes(x=site,y=mu))+geom_point()
#ggplot(allsites,aes(x=site,y=k))+geom_point()
ggplot(subset(allsites,subset=allsites$trt.name=="mu1k1"),aes(x=mu,y=k,colour=site))+geom_point(size=3)

trtcols <- dcast(data=allsites,formula=site+temporal.block+variable~trt.name,value.var="value")

We can get another look at the same data by graphing the amount of rain over time for all treatments at all sites. Each figure is a fieldsite; each has 30 lines showing the water amounts added to every bromeliad over time.

allsites$Day <- as.numeric(gsub(allsites$variable,pattern="[a-zA-Z]+\\.?",replacement=""))
ggplot(allsites,aes(x=Day,y=value,group=trt.name))+geom_path()+facet_wrap(~site)

## remove the temporal block days:
# 
# tmpblock_sites <- split(allsites,allsites$temporal.block)
# 
# no_extra_days <- rbind(tmpblock_sites$a[!tmpblock_sites$a$Day%in%c(1:2,63:68),],
#                        tmpblock_sites$b[!tmpblock_sites$b$Day%in%c(1:3,64:68),],
#                        tmpblock_sites$c[!tmpblock_sites$c$Day%in%c(1:4,65:68),])
# 
# no_extra_days[which(is.na(no_extra_days$value)),]
#ggplot(allsites,aes(x=Day,y=value,group=trt.name))+geom_path()+facet_grid(~mu)

allsites_noNA <- allsites[!is.na(allsites$value),]

#ddply(allsites_noNA,.variables=.(sites),summarize,m)
summary_sites <- ddply(allsites_noNA,.variables=.(site,trt.name),.fun=summarize,
                       maxrain=max(value),
                       drydays=sum(value==0)
                       )

The number of dry days in a treatment depends on both mu and k. Some analyses have suggested that the number of dry days is useful for predicting community responses to the treatments. So, how does each fieldsite differ in the number of dry days per treatment? Each density plot has n=30 (one for every bromeliad in each treatment)

ggplot(summary_sites,aes(x=drydays,colour=site))+geom_density()+xlab("number of dry days")


benmarwick/precipitation_experiment_schedule_package documentation built on May 12, 2019, 1:02 p.m.