-
Notifications
You must be signed in to change notification settings - Fork 5
Silene acaulis
cstubben edited this page Apr 30, 2012
·
5 revisions
The following code will download the 25 projection matrices in Supplement 1 from
Morris, W.F. and D.F. Doak. 2005. How general are the determinants of the stochastic population growth rate across nearby sites? Ecological Monographs 75:119–137.
The matrices are stored in 25 separate comma-delimited files and one file (PA98.txt) has two field delimiters (spaces and commas), so some additional code is added to the loop to fix this error. The paper includes details on the study sites and stage classes which are defined below
site <- c("CC", "GU", "PA", "RG", "RI")
years <- 95:99
stages <- c("seed", "sdling", "1R", "5R", "10R", "20R", "12cm", "25cm", "50cm", "100cm", "200cm", "200+cm")
Paste together the site and year to create the file name, loop through the 25 files and save the results to a list.
pop <- paste(rep(site,each=5),years, sep="")
n <- length(pop)
silene <- vector('list', n)
names(silene) <- pop
for ( i in 1:n)
{
url <- paste("http://www.esapubs.org/archive/mono/M075/004/", pop[i],".txt", sep="")
if(pop[i] == "PA98"){
# missing commas in row 2, last 3 values
y <- read.table(url , sep=",", fill=TRUE, stringsAsFactors=FALSE)
y[2,10:12] <- unlist(strsplit(y[2,10], " "))
}else{
y <- read.table(url, sep=",")
}
y <- data.matrix(y)
dimnames(y) <- list(stages,stages)
silene[[i]] <- y
}
# check results
sapply(silene, lambda)
CC95 CC96 CC97 CC98 CC99 GU95 GU96 GU97 GU98 GU99 PA95 PA96 PA97
0.991 1.006 1.000 1.006 0.999 1.000 0.996 0.998 1.000 1.004 0.995 0.995 1.015
PA98 PA99 RG95 RG96 RG97 RG98 RG99 RI95 RI96 RI97 RI98 RI99
1.034 0.973 0.991 0.985 1.000 1.003 1.000 0.997 1.005 0.983 0.998 1.007
# view mean matrix
image2( mean(silene) , cex=.5, log=FALSE)