Running examples in ‘IPMpack-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: dataIPMpackHypericum
> ### Title: Hypericum Perennial Dataset
> ### Aliases: dataIPMpackHypericum
> ### Keywords: datasets
> 
> ### ** Examples
> 
> 
> #Access data from the long-term censuses on Hypericum cumulicula 
> # carried out by Eric Menges, Pedro Quintana-Ascencio and coworkers 
> # at Archbold Biological Station. Here only a subset of individuals 
> # from population 'bald 1' and for the annual transition '1997-1998' are shown.
> data("dataIPMpackHypericum")
> d<-dataIPMpackHypericum
> 
> #Variables are:
>   #id: unique identifier for each individual
>   #bald: population. Here only bald 1
>   #year: annual transition of the long-term data. Here only 1997-1998
>   #surv: survival (1) or not (0) of individuals between 1997 and 1998
>   #size: maximum height of the stems of each individual
>   #ontogeny: because the demography of Hypericum is very dynamic 
>   #      (turnover is very high) the experimental design described 
>   #       in Quintana-Ascencio et al. (2003) consists on establishing 
>   #       new permanent plots every year at each population, 
>   #       in addition to censusing old plots. Here we differentiate 
>   #       between individuals that appear for the first time in time t 
>   #       because they were recruits (1) and those that, not being new 
>   #       recruits, where measured for the first time in t because they 
>   #       were in a new permanent plot.
>   #fec0: probability of flowering (1) or not (0)
>   #fec1: number of fruits per individual
>   #sizeNext: same as "size" above, for t+1
>   #stageNext: same as "stage" above, for t+1
> 
> #Due to the sampling design described above, here we consider only 
> # individual with a certain recruit origin:
> d <- subset(d,is.na(d$size)==FALSE | d$ontogenyNext==1)
> 
> #Side-experiments revealed that the following vital rates are size-independent 
> # and equal to:
>   #Number of seeds produced per fruit
>     fec2<-13.78
>   #Probability of seedling establishment
>     fec3<-0.001336
>   #Probability of seedling survival half a year after germinating, 
>   #   corresponding to the next annual census
>     fec4<-0.14
>   #Probability of a seed going into the seed bank
>     goSB<-0.08234528
>   #Probability of a seed staying in the seed bank
>     staySB<-0.672
> #Note that the aforementioned vital rates are function of time since last fire, 
> #but because here we are only dealing with one population and one year 
> #transition, we treat them as constants. See Quintana-Ascencio et al (2003) 
> #for more information.
> 
> #A simple re-organization of the data, getting rid of non-critical information
> d<-d[,c("surv","size","sizeNext","fec0","fec1")]
> 
> #The following states the continuous (max height of individual plant) 
> #part of the IPM. Note that the IPM to be constructed here contains a 
> #discrete stage: seedbank.
> d$stageNext<-d$stage<-"continuous"
> d$stage[is.na(d$size)]<-NA
> #If individual did not survive, it is labelled as dead to t+1.
> d$stageNext[d$surv==0]<-"dead"
> #Adds probability of seeds going into (continuous -> seedbank), 
> #staying (seedbank -> seedbank) and leaving (continuous -> seedbank) 
> #the discrete stage.
> d$number<-1
> d$stage<-as.factor(d$stage)
> d$stageNext<-as.factor(d$stageNext)
> 
> #Carry out comparisons to establish the best survival model
> testSurv <- survModelComp(d, expVars = c(surv~1, surv~size, 
+  surv~size + size2), testType = "AIC",makePlot = TRUE,legendPos = "bottomleft")
> 
> #Carry out comparisons to establish the best growth model
> testGrow <- growthModelComp(d,expVars = c(sizeNext~1, sizeNext~size, 
+    sizeNext~size + size2), regressionType = "constantVar", 
+    testType = "AIC", makePlot = TRUE, legendPos = "bottomright")
> 
> #Create survival object using regression model indicated by testSurv
> so <- makeSurvObj(d, Formula = surv~size + size2)
> picSurv(d,so)
> 
> #Create growth object using regression model indicated by testGrown
> go<-makeGrowthObj(d, Formula = sizeNext~size) 
> picGrow(d,go)
> abline(a=0,b=1,lty=2)
> 
> #Create fecundity object using regression models
> fo <- makeFecObj(d, Formula=c(fec0~size, fec1~size),
+                  Family=c("binomial","poisson"),
+                  Transform=c("none", "none"),
+                  meanOffspringSize=mean(d[is.na(d$size)==TRUE & 
+                  is.na(d$sizeNext)==FALSE,"sizeNext"]),
+                  sdOffspringSize=sd(d[is.na(d$size)==TRUE & 
+                  is.na(d$sizeNext)==FALSE,"sizeNext"]),
+                  fecConstants=data.frame(fec2=fec2,fec3=fec3,fec4=fec4),
+                  offspringSplitter=data.frame(seedbank=goSB,
+                     continuous=(1-goSB)),
+                  vitalRatesPerOffspringType=data.frame(seedbank=c(1,1,1,0,0),
+                                                continuous=c(1,1,1,1,1),
+                                                row.names=c("fec0","fec1",
+                                                "fec2","fec3","fec4")))
[1] "Warning - the variable names in your offspringSplitter data.frame are not all part of the levels of stage or stageNext in your data file. This could be because of an mismatch in stage names, or because you included discrete stages in offspringSplitter that are not in the data file but wchich you will introduce in makeDiscreteTrans (in which case you can ignore this warning)."
> 
> 
> #Define discrete transition matrix 
> dto<-makeDiscreteTrans(d, 
+ 		discreteTrans = matrix(c(staySB,(1-staySB)*fec3*fec4,
+ 		(1-staySB)*(1-fec3*fec4),0,
+ 		sum(d$number[d$stage=="continuous"&d$stageNext=="continuous"],
+ 		na.rm=TRUE),sum(d$number[d$stage=="continuous"&d$stageNext=="dead"],
+ 		na.rm=TRUE)),ncol=2,nrow=3,
+ 		dimnames=list(c("seedbank","continuous","dead"),
+ 		c("seedbank","continuous"))),
+ 		meanToCont = matrix(mean(d$sizeNext[is.na(d$stage)&
+ 		d$stageNext=="continuous"]),ncol=1,nrow=1,dimnames=list(c("mean"),
+ 		c("seedbank"))),
+ 		sdToCont = matrix(sd(d$sizeNext[is.na(d$stage)&
+ 		d$stageNext=="continuous"]),ncol=1,nrow=1,dimnames=list(c(""),
+ 		c("seedbank"))))
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
IPMpack
 --- call from context --- 
makeDiscreteTrans(d, discreteTrans = matrix(c(staySB, (1 - staySB) * 
    fec3 * fec4, (1 - staySB) * (1 - fec3 * fec4), 0, sum(d$number[d$stage == 
    "continuous" & d$stageNext == "continuous"], na.rm = TRUE), 
    sum(d$number[d$stage == "continuous" & d$stageNext == "dead"], 
        na.rm = TRUE)), ncol = 2, nrow = 3, dimnames = list(c("seedbank", 
    "continuous", "dead"), c("seedbank", "continuous"))), meanToCont = matrix(mean(d$sizeNext[is.na(d$stage) & 
    d$stageNext == "continuous"]), ncol = 1, nrow = 1, dimnames = list(c("mean"), 
    c("seedbank"))), sdToCont = matrix(sd(d$sizeNext[is.na(d$stage) & 
    d$stageNext == "continuous"]), ncol = 1, nrow = 1, dimnames = list(c(""), 
    c("seedbank"))))
 --- call from argument --- 
if (class(discreteTrans) != "matrix") stop("Error - the discreteTrans you entered should be a matrix")
 --- R stacktrace ---
where 1: makeDiscreteTrans(d, discreteTrans = matrix(c(staySB, (1 - staySB) * 
    fec3 * fec4, (1 - staySB) * (1 - fec3 * fec4), 0, sum(d$number[d$stage == 
    "continuous" & d$stageNext == "continuous"], na.rm = TRUE), 
    sum(d$number[d$stage == "continuous" & d$stageNext == "dead"], 
        na.rm = TRUE)), ncol = 2, nrow = 3, dimnames = list(c("seedbank", 
    "continuous", "dead"), c("seedbank", "continuous"))), meanToCont = matrix(mean(d$sizeNext[is.na(d$stage) & 
    d$stageNext == "continuous"]), ncol = 1, nrow = 1, dimnames = list(c("mean"), 
    c("seedbank"))), sdToCont = matrix(sd(d$sizeNext[is.na(d$stage) & 
    d$stageNext == "continuous"]), ncol = 1, nrow = 1, dimnames = list(c(""), 
    c("seedbank"))))

 --- value of length: 2 type: logical ---
[1] FALSE  TRUE
 --- function from context --- 
function (dataf, stages = NA, discreteTrans = NA, meanToCont = NA, 
    sdToCont = NA, continuousToDiscreteExplanatoryVariables = "size") 
{
    if (is.na(stages[1])) {
        stages <- names(tapply(c(levels(dataf$stage), levels(dataf$stageNext)), 
            c(levels(dataf$stage), levels(dataf$stageNext)), 
            length))
        if (!is.na(discreteTrans[1])) 
            stages <- c(stages, dimnames(discreteTrans)[[2]])
    }
    stages <- unique(stages)
    stages <- c(stages[!stages %in% c("continuous", "dead")], 
        "continuous", "dead")
    if (length(stages) == 2) 
        stop("Error - no discrete stages found. If no discrete stages are included in your data file, please specify them in the discreteTrans argument of the makeDiscreteTrans function.")
    if (("number" %in% names(dataf)) == FALSE) 
        dataf$number <- 1
    nDiscreteClasses <- length(stages) - 2
    if (is.na(discreteTrans[1]) & length(discreteTrans) == 1) {
        discreteTrans <- matrix(0, nrow = nDiscreteClasses + 
            2, ncol = nDiscreteClasses + 1, dimnames = list(stages, 
            stages[1:(length(stages) - 1)]))
        for (j in stages[1:(length(stages) - 1)]) {
            for (i in stages) discreteTrans[i, j] <- sum(dataf[dataf$stage == 
                j & dataf$stageNext == i, ]$number, na.rm = TRUE)
        }
    }
    if (class(discreteTrans) != "matrix") 
        stop("Error - the discreteTrans you entered should be a matrix")
    if (nrow(discreteTrans) != length(stages) | ncol(discreteTrans) != 
        (length(stages) - 1)) 
        stop("Error - the discreteTrans matrix you entered should be a square matrix with dimensions equal to the number of stages (including continuous)")
    if (sum(dimnames(discreteTrans)[[1]] == stages) < length(stages)) 
        stop("Error - the row names of your discreteTrans matrix should be in alphabetical order, with continuous being the last one")
    if (sum(dimnames(discreteTrans)[[2]] == stages[1:(length(stages) - 
        1)]) < (length(stages) - 1)) 
        stop("Error - the column names of your discreteTrans matrix should be in alphabetical order, with continuous being the last one")
    for (j in stages[1:(length(stages) - 1)]) discreteTrans[, 
        j] <- discreteTrans[, j]/sum(discreteTrans[, j], na.rm = TRUE)
    if (is.na(meanToCont[1]) & length(meanToCont) == 1) {
        meanToCont <- matrix(NA, nrow = 1, ncol = nDiscreteClasses, 
            dimnames = list(1, stages[1:nDiscreteClasses]))
        for (j in stages[which(as.numeric(discreteTrans["continuous", 
            1:nDiscreteClasses]) > 0)]) {
            meanToCont[, j] <- mean(dataf[dataf$stage == j & 
                dataf$stageNext == "continuous", ]$sizeNext, 
                na.rm = TRUE)
        }
    }
    if (class(meanToCont) != "matrix") 
        stop("Error - the meanToCont matrix you entered should be a matrix")
    if (nrow(meanToCont) != 1) 
        stop("Error - the meanToCont matrix you entered should contain just 1 row with means (or NA's for those discrete stages from which no individuals move to the continuous class")
    if (sum(dimnames(meanToCont)[[2]] == stages[1:nDiscreteClasses]) < 
        nDiscreteClasses) 
        stop("Error - the column names of the meanToCont matrix you entered should be in alphabetical order and match the column names of the discrete classes in discreteTrans (so without continuous). If some of the discete stages are not mentioned in your data file, this error can be fixed by adding those stages first: levels(dataf$stage)<-c(levels(dataf$stage),<unmentioned_discrete_stages>)")
    if (is.na(sdToCont[1]) & length(sdToCont) == 1) {
        sdToCont <- matrix(NA, nrow = 1, ncol = nDiscreteClasses, 
            dimnames = list(1, stages[1:nDiscreteClasses]))
        for (j in stages[which(as.numeric(discreteTrans["continuous", 
            1:nDiscreteClasses]) > 0)]) {
            sdToCont[, j] <- sd(dataf[dataf$stage == j & dataf$stageNext == 
                "continuous", ]$sizeNext, na.rm = TRUE)
        }
    }
    if (class(sdToCont) != "matrix") 
        stop("Error - the sdToCont matrix you entered should be a matrix")
    if (nrow(sdToCont) != 1) 
        stop("Error - the sdToCont matrix you entered should contain just 1 row with means (or NA's for those discrete stages from which no individuals move to the continuous class")
    if (sum(dimnames(sdToCont)[[2]] == stages[1:nDiscreteClasses]) < 
        nDiscreteClasses) 
        stop("Error - the column names of the sdToCont matrix you entered should be in alphabetical order and match the column names of the discrete classes in discreteTrans (so without continuous). If some of the discete stages are not mentioned in your data file, this error can be fixed by adding those stages first: levels(dataf$stage)<-c(levels(dataf$stage),<unmentioned_discrete_stages>)")
    if (sum(discreteTrans[stages[1:nDiscreteClasses], "continuous"]) == 
        0) {
        moveToDiscrete <- glm(rep(0, 21) ~ 1, family = binomial)
    }
    else {
        subData <- subset(dataf, dataf$stage == "continuous" & 
            dataf$surv == 1)
        subData$contToDiscrete <- 1
        subData$contToDiscrete[subData$stageNext == "continuous"] <- 0
        subData$size2 <- subData$size^2
        subData$size3 <- subData$size^3
        if (length(grep("expsize", as.character(continuousToDiscreteExplanatoryVariables))) > 
            0) 
            subData$expsize <- exp(subData$size)
        if (length(grep("logsize", as.character(continuousToDiscreteExplanatoryVariables))) > 
            0) 
            subData$logsize <- log(subData$size)
        moveToDiscrete <- glm(paste("contToDiscrete~", continuousToDiscreteExplanatoryVariables, 
            sep = ""), family = binomial, data = subData)
    }
    disTrans <- new("discreteTrans")
    disTrans@discreteTrans <- discreteTrans
    disTrans@meanToCont <- meanToCont
    disTrans@sdToCont <- sdToCont
    disTrans@moveToDiscrete <- moveToDiscrete
    return(disTrans)
}
<bytecode: 0x5556715f10a0>
<environment: namespace:IPMpack>
 --- function search by body ---
Function makeDiscreteTrans in namespace IPMpack has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1