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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: mergeStates
> ### Title: mergeStates
> ### Aliases: mergeStates
> ### Keywords: merge mergeStates,
> 
> ### ** Examples
> 
> 
> hfNames <- array(rep("Exponential", 16), dim = c(4,4))
> hfNames[col(hfNames) <= row(hfNames)]<-"NULL"
> rownames(hfNames) <- as.list(paste("state", 1:4))
> colnames(hfNames) <- as.list(paste("state", 1:4))
> M <- makeM(hfNames)
[1] "state 1" "state 2" "state 3" "state 4"
         to
from      state 1 state 2      state 3      state 4     
  state 1 NULL    "impossible" "impossible" "impossible"
  state 2 NULL    NULL         "impossible" "impossible"
  state 3 NULL    NULL         NULL         "impossible"
  state 4 NULL    NULL         NULL         NULL        
> param <- generateParameterMatrix(M)
> param[[1,2]] <- list(rate = 1)
> param[[1,3]] <- list(rate = 2)
> param[[2,3]] <- list(rate = 0.5)
> 
> param[[1,4]] <- list(rate = 1)
> param[[2,4]] <- list(rate = 2)
> param[[3,4]] <- list(rate = 0.5)
> 
> cohort <- simulateCohort(
+ transitionFunctions = M,
+ parameters = param,
+ cohortSize = 100,
+ to=10)
[1] "class(parameters)"
[1] "transition.structure"
attr(,"package")
[1] "GUIgems"
         to
from      state 1 state 2 state 3 state 4
  state 1 NULL    List,1  List,1  List,1 
  state 2 NULL    NULL    List,1  List,1 
  state 3 NULL    NULL    NULL    List,1 
  state 4 NULL    NULL    NULL    NULL   
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
GUIgems
 --- call from context --- 
createCohorts(hazardf = hf, statesNumber = statesNumber, cohortSize = cohortSize, 
    mu = parameters.in, sigma = sigma, historyl = historyDep, 
    impossible = impossible, fixpar = fixpar, direct = direct, 
    bl0 = baseline, startingStates = initialState, absorbing = absorbing, 
    to = to, report.every = report.every, sampler.steps = sampler.steps)
 --- call from argument --- 
if (class(sigma) == "transition.structure") {
    if (dim(sigma)[1] != length(unlist(mu))) 
        stop("size of parameters and parameterCovariances are inconsistent")
}
 --- R stacktrace ---
where 1: createCohorts(hazardf = hf, statesNumber = statesNumber, cohortSize = cohortSize, 
    mu = parameters.in, sigma = sigma, historyl = historyDep, 
    impossible = impossible, fixpar = fixpar, direct = direct, 
    bl0 = baseline, startingStates = initialState, absorbing = absorbing, 
    to = to, report.every = report.every, sampler.steps = sampler.steps)
where 2: simulateCohort(transitionFunctions = M, parameters = param, cohortSize = 100, 
    to = 10)

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (hazardf, statesNumber, statesNamesFrom = strsplit((dimnames(hazardf)["from"])[[1]], 
    " "), statesNamesTo = statesNamesFrom, cohortSize, mu, sigma = matrix(0, 
    nrow = length(unlist(mu)), ncol = length(unlist(mu))), historyl = FALSE, 
    startingStates = rep(1, cohortSize), absorbing = cohortSize, 
    impossible = NULL, fixpar = NULL, direct = NULL, bl0 = matrix(0, 
        nrow = cohortSize), to = 100, report.every, sampler.steps) 
{
    statesNames <- list(from = statesNamesFrom, to = statesNamesTo)
    hazardf <- t(hazardf)[t(auxcounter(statesNumber)) > 0]
    if (length(hazardf) < (statesNumber * (statesNumber - 1)/2)) {
        length(hazardf) <- statesNumber * (statesNumber - 1)/2
    }
    for (tr in 1:length(hazardf)) {
        if (length(hazardf[[tr]]) > 0) {
            if (!is.function(hazardf[[tr]])) {
                if (!hazardf[[tr]] %in% c("Weibull", "multWeibull", 
                  "Exponential", "impossible") && !is.na(hazardf[[tr]])) 
                  try(hazardf[[tr]] <- as.function(hazardf[[tr]]))
            }
        }
    }
    mu <- as.list(unlist(t(mu), recursive = FALSE))
    if (length(mu) > 0) {
        mu <- lapply(mu, as.numeric)
    }
    if (class(sigma) == "transition.structure") {
        if (dim(sigma)[1] != length(unlist(mu))) 
            stop("size of parameters and parameterCovariances are inconsistent")
    }
    if (length(startingStates) == 1) 
        rep(startingStates, cohortSize)
    if (cohortSize > 1) {
        try(bl0 <- as.matrix(bl0))
    }
    else if (is.null(dim(bl0))) {
        try(bl0 <- t(as.matrix(bl0)))
    }
    if (nrow(bl0) != cohortSize) 
        warning("baseline is not of the right dimension")
    for (i in 1:length(hazardf)) {
        if (is.element(i, impossible)) {
            if (historyl == FALSE) 
                hazardf[[i]] = function(t, bl) 99 * to
            else hazardf[[i]] = function(t, history, bl) 99 * 
                to
        }
    }
    parametric = numeric()
    k = 0
    for (i in 1:max(auxcounter(statesNumber))) {
        if (is.character(hazardf[[i]])) {
            k = k + 1
            parametric[k] = i
            if (hazardf[[i]] %in% c("Weibull", "multWeibull", 
                "Exponential")) {
                hazardf[[i]] <- switch(hazardf[[i]], Weibull = function(t, 
                  shape, scale, history, bl) rweibull(t, shape, 
                  scale), multWeibull = function(t, w, shapes, 
                  scales, history, bl) multPar(t, w, shapes, 
                  scales), Exponential = function(t, rate, history, 
                  bl) rexp(t, rate))
                if (!historyl) 
                  formals(hazardf[[i]])$history <- NULL
            }
            else {
                stop(paste("Transition function for transition", 
                  i, "not recognized", sep = " "))
            }
        }
    }
    allFunctions = mainFunctions(statesNumber = statesNumber, 
        Mu = mu, sigma = sigma, cohortSize = cohortSize, history = historyl, 
        hazardf, impossible = c(impossible, fixpar, direct))
    parametric = sort(c(parametric, impossible, direct))
    cohorts <- sapply(1:cohortSize, function(i) {
        if ((i%%report.every == 0) | (i == 1)) 
            message("Simulating patient:", i)
        print(bl0[i, ])
        historical(gf = allFunctions[[i]], statesNumber = statesNumber, 
            parametric = parametric, historyl = historyl, startingState = startingStates[i], 
            absorbing = absorbing, bl = bl0[i, ], to = to, sampler.steps = sampler.steps)[[1]]
    })
    print("dimnames")
    dimnames(cohorts) <- list(statesNamesFrom, paste("Patient", 
        1:cohortSize))
    print("return(cohorts)")
    return(cohorts)
}
<bytecode: 0x562647a748f8>
<environment: namespace:GUIgems>
 --- function search by body ---
Function createCohorts in namespace GUIgems has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1