Error(s) in re-building vignettes:
  ...
--- re-building 'How_to_use_mvMORPH.Rmd' using rmarkdown
Loading required package: phytools
Loading required package: ape
Loading required package: maps
Loading required package: corpcor
Loading required package: subplex
##
## mvMORPH package (1.1.0)
## Multivariate evolutionary models
##
## See the tutorials: browseVignettes("mvMORPH")
##
## To cite package 'mvMORPH': citation("mvMORPH")
##
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
mvMORPH
 --- call from context --- 
mvSIM(tree, param = list(sigma = sigma, alpha = alpha, theta = theta, 
    root = TRUE), model = "OU1", nsim = 1)
 --- call from argument --- 
if (length(param$sigma) == k & class(param$sigma) != "list") {
    sigma <- lapply(1:k, function(x) {
        runif(n = 1)
    })
    if (p != 1) {
        sigma <- lapply(1:k, function(x) {
            diag(p)
        })
    }
} else if (model != "OUBMi" & model != "BMOUi" & model != "OUEBi" & 
    model != "EBOUi" & model != "BMEBi" & model != "EBBMi" & 
    model != "RR" & model != "RC") {
    sigma <- sig <- param$sigma
} else {
    sigma <- param$sigma[[1]]
    sig <- param$sigma[[2]]
}
 --- R stacktrace ---
where 1: mvSIM(tree, param = list(sigma = sigma, alpha = alpha, theta = theta, 
    root = TRUE), model = "OU1", nsim = 1)
where 2: eval(expr, envir, enclos)
where 3: eval(expr, envir, enclos)
where 4: withVisible(eval(expr, envir, enclos))
where 5: withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler, 
    error = eHandler, message = mHandler)
where 6: handle(ev <- withCallingHandlers(withVisible(eval(expr, envir, 
    enclos)), warning = wHandler, error = eHandler, message = mHandler))
where 7: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr, 
    envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
where 8: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, 
    debug = debug, last = i == length(out), use_try = stop_on_error != 
        2L, keep_warning = keep_warning, keep_message = keep_message, 
    output_handler = output_handler, include_timing = include_timing)
where 9: evaluate::evaluate(...)
where 10: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), 
    keep_message = !isFALSE(options$message), stop_on_error = if (options$error && 
        options$include) 0L else 2L, output_handler = knit_handlers(options$render, 
        options))
where 11: in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE, 
    keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), 
    stop_on_error = if (options$error && options$include) 0L else 2L, 
    output_handler = knit_handlers(options$render, options)))
where 12: block_exec(params)
where 13: call_block(x)
where 14: process_group.block(group)
where 15: process_group(group)
where 16: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), 
    error = function(e) {
        setwd(wd)
        cat(res, sep = "\n", file = output %n% "")
        message("Quitting from lines ", paste(current_lines(i), 
            collapse = "-"), " (", knit_concord$get("infile"), 
            ") ")
    })
where 17: process_file(text, output)
where 18: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet, 
    encoding = encoding)
where 19: rmarkdown::render(file, encoding = encoding, quiet = quiet, envir = globalenv(), 
    ...)
where 20: vweave_rmarkdown(...)
where 21: engine$weave(file, quiet = quiet, encoding = enc)
where 22: doTryCatch(return(expr), name, parentenv, handler)
where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 24: tryCatchList(expr, classes, parentenv, handlers)
where 25: tryCatch({
    engine$weave(file, quiet = quiet, encoding = enc)
    setwd(startdir)
    output <- find_vignette_product(name, by = "weave", engine = engine)
    if (!have.makefile && vignette_is_tex(output)) {
        texi2pdf(file = output, clean = FALSE, quiet = quiet)
        output <- find_vignette_product(name, by = "texi2pdf", 
            engine = engine)
    }
}, error = function(e) {
    OK <<- FALSE
    message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s", 
        file, conditionMessage(e)))
})
where 26: tools:::.buildOneVignette("How_to_use_mvMORPH.Rmd", "/home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/mvMORPH.Rcheck/vign_test/mvMORPH", 
    TRUE, FALSE, "How_to_use_mvMORPH", "", "/tmp/RtmpyGMMDY/file6b164555f18d.rds")

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (tree, nsim = 1, error = NULL, model = c("BM1", "BMM", 
    "OU1", "OUM", "EB"), param = list(theta = 0, sigma = 0.1, 
    alpha = 1, beta = 0)) 
{
    if (any(class(param) == "mvmorph")) {
        model <- param$param$model[1]
        p <- param$param$ntraits
        n <- param$param$nbspecies
        k <- param$param$nregimes
        mu <- param$theta
        sigma <- param$sigma
        names_traits <- param$param$traits
        if (model == "BM1" | model == "BMM") {
            param$smean <- param$param$smean
        }
        else {
            param$smean <- TRUE
        }
        if (is.null(param$param[["root"]])) {
            root <- FALSE
        }
        else {
            root <- param$param$root
        }
        if (is.null(param$param[["trend"]])) {
            istrend <- FALSE
        }
        else if (param$param$trend == FALSE) {
            istrend <- FALSE
        }
        else {
            istrend <- TRUE
            trend <- as.vector(param$trend)
        }
        if (any(class(param) == "mvmorph.shift")) {
            before <- param$param$before
            after <- param$param$after
        }
        if (model == "ER") {
            alpha <- param$alpha
            sig <- param$sigma
        }
        else if (model == "RR") {
            alpha <- param$alpha
            sig <- param$sig
        }
        if (model == "OV") {
            alpha <- param$alpha
            beta <- matrix(param$beta, p, p)
            sig <- param$sigma
        }
        else if (model == "OVG") {
            alpha <- param$alpha
            sig <- param$sig
            beta <- matrix(param$beta, p, p)
        }
        if (model == "CV") {
            beta <- matrix(param$beta, p, p)
            sig <- param$sigma
        }
        else if (model == "CVG") {
            beta <- matrix(param$beta, p, p)
            sig <- param$sig
        }
        if (model == "OUM" | model == "OU1" | model == "OUTS") {
            alpha <- param$alpha
            param$vcv <- param$param$vcv
        }
        if (model == "BMM") {
            sigma <- lapply(1:k, function(x) {
                sigma[, , x]
            })
        }
        if (any(class(param) == "mvmorph.acdc")) {
            beta <- matrix(param$beta, p, p)
            model <- "EB"
        }
    }
    else {
        model <- model[1]
        if (missing(tree)) 
            stop("The tree or the time-series object is missing")
        if (model == "ACDC" | model == "AC") {
            model <- "EB"
        }
        if (is.null(param[["names_traits"]])) {
            names_traits <- NULL
        }
        else {
            names_traits <- param$names_traits
        }
        if (model == "BM1" | model == "OU1" | model == "EB") {
            k <- 1
        }
        else {
            if (inherits(tree, "phylo")) {
                if (!is.null(tree[["mapped.edge"]])) {
                  k <- length(colnames(tree$mapped.edge))
                }
            }
            else {
                k <- 1
            }
        }
        if (is.null(param[["root"]])) {
            root <- param$root <- FALSE
            if (model == "OUTS") 
                root <- param$root <- TRUE
        }
        else {
            root <- param$root
        }
        if (is.null(param[["ntraits"]])) {
            if (!is.null(param[["alpha"]])) {
                p <- dim(as.matrix(param$alpha))[1]
            }
            else if (!is.null(param[["sigma"]])) {
                if (model == "BMM") {
                  p <- dim(as.matrix(param$sigma[[1]]))[1]
                }
                else {
                  p <- dim(as.matrix(param$sigma))[1]
                }
            }
            else {
                p <- 1
                cat("default simulations for 1 trait. Use \"ntraits\" argument in the \"param\" list  ", 
                  "\n")
            }
        }
        else {
            p <- param$ntraits
        }
        if (root == TRUE) {
            k <- k + 1
        }
        if (!is.null(param[["mu"]])) {
            param$theta <- param$mu
        }
        if (is.null(param[["theta"]]) == TRUE) {
            if (model == "OUM") {
                mu <- rep(0, k)
                if (p != 1) {
                  mu <- rep(0, k * p)
                }
            }
            else {
                mu <- 0
                if (p != 1) {
                  mu <- rep(0, p)
                }
            }
            cat("No values provided for theta, default value fixed to:", 
                mu, "\n")
        }
        else {
            if (p == 1) {
                if (k == 1) {
                  mu <- param$theta
                }
                else if (length(param$theta) != k & model == 
                  "OUM") {
                  mu <- rep(0, k)
                  cat("Problems with theta values provided, default value fixed to:", 
                    mu, "\n")
                }
                else {
                  mu <- param$theta
                }
            }
            else {
                if (k == 1) {
                  mu <- param$theta
                }
                else if (length(param$theta) != k * p & model == 
                  "OUM") {
                  mu <- rep(0, k * p)
                  cat("Problems with theta values provided, default value fixed to:", 
                    mu, "\n")
                }
                else {
                  mu <- param$theta
                }
            }
        }
        if (is.null(param[["sigma"]]) == TRUE) {
            if (model == "BMM") {
                sigma <- lapply(1:k, function(x) {
                  runif(n = 1)
                })
                if (p != 1) {
                  sigma <- lapply(1:k, function(x) {
                    diag(p)
                  })
                }
            }
            else {
                sigma <- sig <- 0.1
                if (p != 1) {
                  sigma <- sig <- diag(p)
                }
            }
            print("No values provided for sigma, default value fixed to:", 
                unlist(sigma), "\n")
        }
        else {
            if (k == 1) {
                sigma <- sig <- param$sigma
            }
            else if (length(param$sigma) != k & model == "BMM") {
                sigma <- lapply(1:k, function(x) {
                  runif(n = 1)
                })
                if (p != 1) {
                  sigma <- lapply(1:k, function(x) {
                    diag(p)
                  })
                }
            }
            else if (length(param$sigma) == k & class(param$sigma) != 
                "list") {
                sigma <- lapply(1:k, function(x) {
                  runif(n = 1)
                })
                if (p != 1) {
                  sigma <- lapply(1:k, function(x) {
                    diag(p)
                  })
                }
            }
            else if (model != "OUBMi" & model != "BMOUi" & model != 
                "OUEBi" & model != "EBOUi" & model != "BMEBi" & 
                model != "EBBMi" & model != "RR" & model != "RC") {
                sigma <- sig <- param$sigma
            }
            else {
                sigma <- param$sigma[[1]]
                sig <- param$sigma[[2]]
            }
        }
        if (model == "EC" || model == "RC" || model == "BMOU" || 
            model == "BMOUi") {
            before <- 2
            after <- 1
            if (model == "EC" || model == "BMOU") {
                model <- "ER"
            }
            else if (model == "RC" || model == "BMOUi") {
                model <- "RR"
            }
        }
        else if (model == "ER" || model == "RR" || model == "OUBM" || 
            model == "OUBMi") {
            before <- 1
            after <- 2
            if (model == "RR" || model == "OUBMi") {
                model <- "RR"
            }
            else if (model == "ER" || model == "OUBM") {
                model <- "ER"
            }
        }
        else if (model == "EBOU" || model == "EBOUi") {
            before <- 2
            after <- 1
            if (model == "EBOU") {
                model <- "OV"
            }
            else if (model == "EBOUi") {
                model <- "OVG"
            }
        }
        else if (model == "OUEB" || model == "OUEBi") {
            before <- 1
            after <- 2
            if (model == "OUEB") {
                model <- "OV"
            }
            else if (model == "OUEBi") {
                model <- "OVG"
            }
        }
        else if (model == "EBBM" || model == "EBBMi") {
            before <- 2
            after <- 1
            if (model == "EBBM") {
                model <- "CV"
            }
            else if (model == "EBBMi") {
                model <- "CVG"
            }
        }
        else if (model == "BMEB" || model == "BMEBi") {
            before <- 1
            after <- 2
            if (model == "BMEB") {
                model <- "CV"
            }
            else if (model == "BMEBi") {
                model <- "CVG"
            }
        }
        if (model == "RR" | model == "ER" | model == "OVG" | 
            model == "OV" | model == "CV" | model == "CVG") {
            if (!is.null(param[["age"]])) {
                tot <- max(nodeHeights(tree))
                limit = tot - param$age
                tree <- make.era.map(tree, c(0, limit))
            }
        }
        if (model == "OU1" | model == "OUM" | model == "RR" | 
            model == "ER" | model == "OVG" | model == "OV" | 
            model == "OUTS") {
            if (is.null(param[["alpha"]]) == TRUE) {
                alpha <- 1
                if (p != 1) {
                  alpha <- diag(p)
                }
                cat("No values provided for alpha, default value fixed to:", 
                  alpha, "\n")
            }
            else {
                alpha <- param$alpha
            }
        }
        if (model == "EB" | model == "CV" | model == "CVG" | 
            model == "OVG" | model == "OV") {
            if (is.null(param[["beta"]]) == TRUE) {
                beta <- 1
                cat("No values provided for beta, default value fixed to:", 
                  beta, "\n")
                if (p != 1) {
                  beta <- matrix(1, p, p)
                }
            }
            else {
                beta <- param$beta
                if (p != 1) {
                  beta <- matrix(param$beta, p, p)
                }
            }
        }
        if (is.null(param[["trend"]])) {
            istrend <- FALSE
        }
        else {
            istrend <- TRUE
            trend <- param$trend
            if (length(trend) < p) {
                stop("The number of specified values for the slopes of the trend do not match the number of traits!", 
                  "\n")
            }
        }
        if (model == "BMM") {
            sigmadim <- length(sigma[[1]])
        }
        else {
            sigmadim <- length(sigma)
        }
        if (sigmadim != p * p) {
            stop("The number of specified traits do not match the parameters matrix dimensions!", 
                "\n")
        }
    }
    if (root == "stationary") {
        mod_stand <- 1
    }
    else {
        mod_stand <- 0
    }
    if (inherits(tree, "phylo")) {
        if (model == "OUTS" | model == "RWTS") 
            stop("Error! you must provides a time-series, not a phylo object.")
        n <- length(tree$tip.label)
        if (model == "OU1" | model == "BM1" | model == "EB") {
            C <- vcv.phylo(tree)
        }
        else {
            C <- vcvSplit(tree)
        }
        names_rows <- tree$tip.label
    }
    else {
        tree <- tree - min(tree)
        C <- vcv.ts(tree)
        n <- length(tree)
        if (is.matrix(tree)) {
            names_rows <- rownames(tree)
        }
        else {
            names_rows <- names(tree)
        }
    }
    if (model == "OUM" | model == "OU1" | model == "OUTS") {
        if (is.null(param[["vcv"]])) {
            vcv <- param$vcv <- "randomRoot"
        }
        else {
            vcv <- param$vcv
        }
        if (model == "OUTS") {
            if (is.null(error) & vcv == "fixedRoot" | any(error[1, 
                ] == 0) & vcv == "fixedRoot") {
                warning("No sampling error provided for the initial observation(s) while using the \"fixedRoot\" parameterization.", 
                  "\n", "An arbitrary sampling error value is set to 0.01 for the initial observation(s) to avoid singularity issues. ")
                if (any(error[1, ] == 0) == TRUE) {
                  if (p == 1) {
                    error[1] <- 0.01
                  }
                  else {
                    error[1, ] <- 0.01
                  }
                }
                else {
                  error <- matrix(0, ncol = p, nrow = n)
                  error[1, ] <- 0.01
                }
            }
        }
    }
    if (model == "RWTS") {
        if (is.null(error) | any(error[1, ] == 0)) {
            warning("No sampling error provided for the initial observation(s).", 
                "\n", "An arbitrary sampling error value is set to 0.01 for the initial observation(s) to avoid singularity issues. ")
            if (any(error[1, ] == 0) == TRUE) {
                if (p == 1) {
                  error[1] <- 0.01
                }
                else {
                  error[1, ] <- 0.01
                }
            }
            else {
                error <- matrix(0, ncol = p, nrow = n)
                error[1, ] <- 0.01
            }
        }
    }
    if (!is.null(error)) {
        error <- as.vector(as.matrix(error))
        error[is.na(error)] <- 0
    }
    if (is.null(param[["method"]])) {
        methodSim <- "cholesky"
    }
    else {
        methodSim <- param$method
    }
    switch(model, RWTS = {
        param$smean <- TRUE
        W <- multD(tree, p, n, smean = param$smean)
        V <- .Call(kronecker_mvmorph, R = sigma, C = C, Rrows = as.integer(p), 
            Crows = as.integer(n))
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (istrend == TRUE) {
            Vdiag <- rep(diag(C), p)
            W <- W %*% as.numeric(mu) + Vdiag * (W %*% trend)
            mu <- as.numeric(1)
        }
    }, BM1 = {
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        if (istrend == FALSE & is.null(error) & p != 1 & param$smean) {
            Croot <- chol(C)
            W <- matrix(1, nrow = n, ncol = 1)
            if (nsim == 1 & p != 1) {
                X <- rmvnorm_simul(n = n, mean = rep(0, p), var = sigma, 
                  method = methodSim)
                deviates <- t(X %*% Croot)
                traits <- matrix(W %*% as.numeric(mu), ncol = p) + 
                  deviates
                rownames(traits) <- names_rows
                colnames(traits) <- names_traits
                return(traits)
            } else if (nsim > 1 & p != 1) {
                traits <- lapply(1:nsim, function(x) {
                  X <- rmvnorm_simul(n = n, mean = rep(0, p), 
                    var = sigma, method = methodSim)
                  deviates <- t(X %*% Croot)
                  traits <- matrix(W %*% as.numeric(mu), ncol = p) + 
                    deviates
                  rownames(traits) <- names_rows
                  colnames(traits) <- names_traits
                  traits
                })
                return(traits)
            }
        }
        W <- multD(tree, p, n, smean = param$smean)
        V <- .Call(kronecker_mvmorph, R = sigma, C = C, Rrows = as.integer(p), 
            Crows = as.integer(n))
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (istrend == TRUE) {
            Vdiag <- rep(diag(C), p)
            W <- W %*% as.numeric(mu) + Vdiag * (W %*% trend)
            mu <- as.numeric(1)
        }
    }, BMM = {
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        V <- .Call(kroneckerSum, R = sigma, C = C, Rrows = as.integer(p), 
            Crows = as.integer(n), dimlist = as.integer(k))
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (istrend == TRUE) {
            Vdiag <- rep(diag(Reduce("+", C)), p)
            W <- W %*% as.numeric(mu) + Vdiag * (W %*% trend)
            mu <- as.numeric(1)
        }
    }, OUTS = {
        eig <- eigen(alpha)
        svec <- try(solve(eig$vectors), silent = TRUE)
        if (inherits(svec, "try-error")) {
            warning("An error occured with the inverse of the orthogonal matrix, the \"pseudoinverse\" has been used instead")
            svec <- pseudoinverse(eig$vectors)
        }
        matdiag <- diag(p)
        if (vcv == "fixedRoot" | vcv == "univarpfFixed" | vcv == 
            "univarFixed" | vcv == "sparse") {
            V <- .Call(mvmorph_covar_mat, as.integer(n), bt = C, 
                lambda = eig$values, S = eig$vectors, sigmasq = sigma, 
                S1 = svec)
        } else if (vcv == "randomRoot" | vcv == "univarpfRandom" | 
            vcv == "univarRandom") {
            V <- .Call(simmap_covar, as.integer(n), bt = C, lambda = eig$values, 
                S = eig$vectors, S1 = svec, sigmasq = sigma)
        }
        if (root == TRUE) {
            W <- .Call(Weight_matrix, S1 = svec, S = eig$vectors, 
                lambda = eig$values, time = as.numeric(tree), 
                matdiag = as.numeric(matdiag))
        } else {
            W <- multD(NULL, p, n, smean = TRUE)
        }
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, OU1 = {
        param_ou <- mv.Precalc(tree, nb.traits = p, param = list(model = "OU1", 
            root = root))
        epochs <- param_ou$epochs
        listReg <- param_ou$listReg
        bt <- param_ou$C1
        eig <- eigen(alpha)
        svec <- try(solve(eig$vectors), silent = TRUE)
        if (inherits(svec, "try-error")) {
            warning("An error occured with the inverse of the orthogonal matrix, the \"pseudoinverse\" has been used instead")
            svec <- pseudoinverse(eig$vectors)
        }
        if (vcv == "fixedRoot" | vcv == "univarpfFixed" | vcv == 
            "univarFixed" | vcv == "sparse") {
            V <- .Call(mvmorph_covar_mat, as.integer(n), bt = bt, 
                lambda = eig$values, S = eig$vectors, sigmasq = sigma, 
                S1 = svec)
        } else if (vcv == "randomRoot" | vcv == "univarpfRandom" | 
            vcv == "univarRandom") {
            V <- .Call(simmap_covar, as.integer(n), bt = bt, 
                lambda = eig$values, S = eig$vectors, S1 = svec, 
                sigmasq = sigma)
        }
        W <- .Call(mvmorph_weights, nterm = as.integer(n), epochs = epochs, 
            lambda = eig$values, S = eig$vectors, S1 = svec, 
            beta = listReg, root = as.integer(mod_stand))
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, OUM = {
        param_ou <- mv.Precalc(tree, nb.traits = p, param = list(model = "OUM", 
            root = root))
        epochs <- param_ou$epochs
        listReg <- param_ou$listReg
        bt <- param_ou$C1
        eig <- eigen(alpha)
        svec <- try(solve(eig$vectors), silent = TRUE)
        if (inherits(svec, "try-error")) {
            warning("An error occured with the inverse of the orthogonal matrix, the \"pseudoinverse\" has been used instead")
            svec <- pseudoinverse(eig$vectors)
        }
        if (vcv == "fixedRoot" | vcv == "univarpfFixed" | vcv == 
            "univarFixed" | vcv == "sparse") {
            V <- .Call(mvmorph_covar_mat, as.integer(n), bt = bt, 
                lambda = eig$values, S = eig$vectors, sigmasq = sigma, 
                S1 = svec)
        } else if (vcv == "randomRoot" | vcv == "univarpfRandom" | 
            vcv == "univarRandom") {
            V <- .Call(simmap_covar, as.integer(n), bt = bt, 
                lambda = eig$values, S = eig$vectors, S1 = svec, 
                sigmasq = sigma)
        }
        W <- .Call(mvmorph_weights, nterm = as.integer(n), epochs = epochs, 
            lambda = eig$values, S = eig$vectors, S1 = svec, 
            beta = listReg, root = as.integer(mod_stand))
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, EB = {
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        V <- .Call(kroneckerEB, R = sigma, C = C, beta = beta, 
            Rrows = as.integer(p), Crows = as.integer(n))
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, RR = {
        if (p == 1) {
            Vou <- .Call(mvmorph_covar_ou_fixed, A = C[[before]], 
                alpha = alpha, sigma = sigma)
        } else {
            eig <- eigen(alpha)
            Vou <- .Call(mvmorph_covar_mat, nterm = as.integer(n), 
                bt = C[[before]], lambda = eig$values, S = eig$vectors, 
                sigmasq = sigma, S1 = solve(eig$vectors))
        }
        V <- .Call(kronecker_shift, R = sig, C = C[[after]], 
            Rrows = as.integer(p), Crows = as.integer(n), V = Vou)
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, ER = {
        if (p == 1) {
            Vou <- .Call(mvmorph_covar_ou_fixed, A = C[[before]], 
                alpha = alpha, sigma = sigma)
        } else {
            eig <- eigen(alpha)
            Vou <- .Call(mvmorph_covar_mat, nterm = as.integer(n), 
                bt = C[[before]], lambda = eig$values, S = eig$vectors, 
                sigmasq = sigma, S1 = solve(eig$vectors))
        }
        V <- .Call(kronecker_shift, R = sig, C = C[[after]], 
            Rrows = as.integer(p), Crows = as.integer(n), V = Vou)
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, CV = {
        V <- .Call(kronecker_shiftEB_BM, R1 = sig, R2 = sigma, 
            C1 = C[[before]], C2 = C[[after]], beta = alpha, 
            Rrows = as.integer(p), Crows = as.integer(n))
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, CVG = {
        V <- .Call(kronecker_shiftEB_BM, R1 = sig, R2 = sigma, 
            C1 = C[[before]], C2 = C[[after]], beta = alpha, 
            Rrows = as.integer(p), Crows = as.integer(n))
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, OV = {
        if (p == 1) {
            Vou <- .Call(mvmorph_covar_ou_fixed, A = C[[before]], 
                alpha = alpha, sigma = sigma)
        } else {
            eig <- eigen(alpha)
            Vou <- .Call(mvmorph_covar_mat, nterm = as.integer(n), 
                bt = C[[before]], lambda = eig$values, S = eig$vectors, 
                sigmasq = sigma, S1 = solve(eig$vectors))
        }
        V <- .Call(kronecker_shiftEB_OU, R = sig, C = C[[after]], 
            beta = beta, Rrows = as.integer(p), Crows = as.integer(n), 
            V = Vou)
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, OVG = {
        if (p == 1) {
            Vou <- .Call(mvmorph_covar_ou_fixed, A = C[[before]], 
                alpha = alpha, sigma = sigma)
        } else {
            eig <- eigen(alpha)
            Vou <- .Call(mvmorph_covar_mat, nterm = as.integer(n), 
                bt = C[[before]], lambda = eig$values, S = eig$vectors, 
                sigmasq = sigma, S1 = solve(eig$vectors))
        }
        V <- .Call(kronecker_shiftEB_OU, R = sig, C = C[[after]], 
            beta = beta, Rrows = as.integer(p), Crows = as.integer(n), 
            V = Vou)
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    })
    if (nsim == 1) {
        traits <- matrix(rmvnorm_simul(n = 1, as.numeric(W %*% 
            as.numeric(mu)), V, methodSim), ncol = p)
        rownames(traits) <- names_rows
        colnames(traits) <- names_traits
    }
    else if (nsim > 1 & p != 1) {
        traits <- lapply(1:nsim, function(x) {
            traits <- matrix(rmvnorm_simul(n = 1, as.numeric(W %*% 
                as.numeric(mu)), V, methodSim), ncol = p)
            rownames(traits) <- names_rows
            colnames(traits) <- names_traits
            traits
        })
    }
    else {
        traits <- matrix(rmvnorm_simul(n = nsim, as.numeric(W %*% 
            as.numeric(mu)), V, methodSim), ncol = nsim)
        rownames(traits) <- names_rows
    }
    return(traits)
}
<bytecode: 0x96b3de0>
<environment: namespace:mvMORPH>
 --- function search by body ---
Function mvSIM in namespace mvMORPH has this body.
 ----------- END OF FAILURE REPORT -------------- 
Quitting from lines 281-292 (How_to_use_mvMORPH.Rmd) 
Error: processing vignette 'How_to_use_mvMORPH.Rmd' failed with diagnostics:
the condition has length > 1
--- failed re-building 'How_to_use_mvMORPH.Rmd'

--- re-building 'tutorial_mvMORPH.Rmd' using rmarkdown
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
mvMORPH
 --- call from context --- 
mvSIM(tree, param = list(sigma = sigma, alpha = alpha, ntraits = 2, 
    theta = theta, names_traits = c("limb.length", "limb.width")), 
    model = "OUM", nsim = 1)
 --- call from argument --- 
if (length(param$sigma) == k & class(param$sigma) != "list") {
    sigma <- lapply(1:k, function(x) {
        runif(n = 1)
    })
    if (p != 1) {
        sigma <- lapply(1:k, function(x) {
            diag(p)
        })
    }
} else if (model != "OUBMi" & model != "BMOUi" & model != "OUEBi" & 
    model != "EBOUi" & model != "BMEBi" & model != "EBBMi" & 
    model != "RR" & model != "RC") {
    sigma <- sig <- param$sigma
} else {
    sigma <- param$sigma[[1]]
    sig <- param$sigma[[2]]
}
 --- R stacktrace ---
where 1: mvSIM(tree, param = list(sigma = sigma, alpha = alpha, ntraits = 2, 
    theta = theta, names_traits = c("limb.length", "limb.width")), 
    model = "OUM", nsim = 1)
where 2: eval(expr, envir, enclos)
where 3: eval(expr, envir, enclos)
where 4: withVisible(eval(expr, envir, enclos))
where 5: withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler, 
    error = eHandler, message = mHandler)
where 6: handle(ev <- withCallingHandlers(withVisible(eval(expr, envir, 
    enclos)), warning = wHandler, error = eHandler, message = mHandler))
where 7: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr, 
    envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
where 8: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, 
    debug = debug, last = i == length(out), use_try = stop_on_error != 
        2L, keep_warning = keep_warning, keep_message = keep_message, 
    output_handler = output_handler, include_timing = include_timing)
where 9: evaluate::evaluate(...)
where 10: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), 
    keep_message = !isFALSE(options$message), stop_on_error = if (options$error && 
        options$include) 0L else 2L, output_handler = knit_handlers(options$render, 
        options))
where 11: in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE, 
    keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), 
    stop_on_error = if (options$error && options$include) 0L else 2L, 
    output_handler = knit_handlers(options$render, options)))
where 12: block_exec(params)
where 13: call_block(x)
where 14: process_group.block(group)
where 15: process_group(group)
where 16: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), 
    error = function(e) {
        setwd(wd)
        cat(res, sep = "\n", file = output %n% "")
        message("Quitting from lines ", paste(current_lines(i), 
            collapse = "-"), " (", knit_concord$get("infile"), 
            ") ")
    })
where 17: process_file(text, output)
where 18: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet, 
    encoding = encoding)
where 19: rmarkdown::render(file, encoding = encoding, quiet = quiet, envir = globalenv(), 
    ...)
where 20: vweave_rmarkdown(...)
where 21: engine$weave(file, quiet = quiet, encoding = enc)
where 22: doTryCatch(return(expr), name, parentenv, handler)
where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 24: tryCatchList(expr, classes, parentenv, handlers)
where 25: tryCatch({
    engine$weave(file, quiet = quiet, encoding = enc)
    setwd(startdir)
    output <- find_vignette_product(name, by = "weave", engine = engine)
    if (!have.makefile && vignette_is_tex(output)) {
        texi2pdf(file = output, clean = FALSE, quiet = quiet)
        output <- find_vignette_product(name, by = "texi2pdf", 
            engine = engine)
    }
}, error = function(e) {
    OK <<- FALSE
    message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s", 
        file, conditionMessage(e)))
})
where 26: tools:::.buildOneVignette("tutorial_mvMORPH.Rmd", "/home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/mvMORPH.Rcheck/vign_test/mvMORPH", 
    TRUE, FALSE, "tutorial_mvMORPH", "", "/tmp/RtmpyGMMDY/file6b162269d05.rds")

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (tree, nsim = 1, error = NULL, model = c("BM1", "BMM", 
    "OU1", "OUM", "EB"), param = list(theta = 0, sigma = 0.1, 
    alpha = 1, beta = 0)) 
{
    if (any(class(param) == "mvmorph")) {
        model <- param$param$model[1]
        p <- param$param$ntraits
        n <- param$param$nbspecies
        k <- param$param$nregimes
        mu <- param$theta
        sigma <- param$sigma
        names_traits <- param$param$traits
        if (model == "BM1" | model == "BMM") {
            param$smean <- param$param$smean
        }
        else {
            param$smean <- TRUE
        }
        if (is.null(param$param[["root"]])) {
            root <- FALSE
        }
        else {
            root <- param$param$root
        }
        if (is.null(param$param[["trend"]])) {
            istrend <- FALSE
        }
        else if (param$param$trend == FALSE) {
            istrend <- FALSE
        }
        else {
            istrend <- TRUE
            trend <- as.vector(param$trend)
        }
        if (any(class(param) == "mvmorph.shift")) {
            before <- param$param$before
            after <- param$param$after
        }
        if (model == "ER") {
            alpha <- param$alpha
            sig <- param$sigma
        }
        else if (model == "RR") {
            alpha <- param$alpha
            sig <- param$sig
        }
        if (model == "OV") {
            alpha <- param$alpha
            beta <- matrix(param$beta, p, p)
            sig <- param$sigma
        }
        else if (model == "OVG") {
            alpha <- param$alpha
            sig <- param$sig
            beta <- matrix(param$beta, p, p)
        }
        if (model == "CV") {
            beta <- matrix(param$beta, p, p)
            sig <- param$sigma
        }
        else if (model == "CVG") {
            beta <- matrix(param$beta, p, p)
            sig <- param$sig
        }
        if (model == "OUM" | model == "OU1" | model == "OUTS") {
            alpha <- param$alpha
            param$vcv <- param$param$vcv
        }
        if (model == "BMM") {
            sigma <- lapply(1:k, function(x) {
                sigma[, , x]
            })
        }
        if (any(class(param) == "mvmorph.acdc")) {
            beta <- matrix(param$beta, p, p)
            model <- "EB"
        }
    }
    else {
        model <- model[1]
        if (missing(tree)) 
            stop("The tree or the time-series object is missing")
        if (model == "ACDC" | model == "AC") {
            model <- "EB"
        }
        if (is.null(param[["names_traits"]])) {
            names_traits <- NULL
        }
        else {
            names_traits <- param$names_traits
        }
        if (model == "BM1" | model == "OU1" | model == "EB") {
            k <- 1
        }
        else {
            if (inherits(tree, "phylo")) {
                if (!is.null(tree[["mapped.edge"]])) {
                  k <- length(colnames(tree$mapped.edge))
                }
            }
            else {
                k <- 1
            }
        }
        if (is.null(param[["root"]])) {
            root <- param$root <- FALSE
            if (model == "OUTS") 
                root <- param$root <- TRUE
        }
        else {
            root <- param$root
        }
        if (is.null(param[["ntraits"]])) {
            if (!is.null(param[["alpha"]])) {
                p <- dim(as.matrix(param$alpha))[1]
            }
            else if (!is.null(param[["sigma"]])) {
                if (model == "BMM") {
                  p <- dim(as.matrix(param$sigma[[1]]))[1]
                }
                else {
                  p <- dim(as.matrix(param$sigma))[1]
                }
            }
            else {
                p <- 1
                cat("default simulations for 1 trait. Use \"ntraits\" argument in the \"param\" list  ", 
                  "\n")
            }
        }
        else {
            p <- param$ntraits
        }
        if (root == TRUE) {
            k <- k + 1
        }
        if (!is.null(param[["mu"]])) {
            param$theta <- param$mu
        }
        if (is.null(param[["theta"]]) == TRUE) {
            if (model == "OUM") {
                mu <- rep(0, k)
                if (p != 1) {
                  mu <- rep(0, k * p)
                }
            }
            else {
                mu <- 0
                if (p != 1) {
                  mu <- rep(0, p)
                }
            }
            cat("No values provided for theta, default value fixed to:", 
                mu, "\n")
        }
        else {
            if (p == 1) {
                if (k == 1) {
                  mu <- param$theta
                }
                else if (length(param$theta) != k & model == 
                  "OUM") {
                  mu <- rep(0, k)
                  cat("Problems with theta values provided, default value fixed to:", 
                    mu, "\n")
                }
                else {
                  mu <- param$theta
                }
            }
            else {
                if (k == 1) {
                  mu <- param$theta
                }
                else if (length(param$theta) != k * p & model == 
                  "OUM") {
                  mu <- rep(0, k * p)
                  cat("Problems with theta values provided, default value fixed to:", 
                    mu, "\n")
                }
                else {
                  mu <- param$theta
                }
            }
        }
        if (is.null(param[["sigma"]]) == TRUE) {
            if (model == "BMM") {
                sigma <- lapply(1:k, function(x) {
                  runif(n = 1)
                })
                if (p != 1) {
                  sigma <- lapply(1:k, function(x) {
                    diag(p)
                  })
                }
            }
            else {
                sigma <- sig <- 0.1
                if (p != 1) {
                  sigma <- sig <- diag(p)
                }
            }
            print("No values provided for sigma, default value fixed to:", 
                unlist(sigma), "\n")
        }
        else {
            if (k == 1) {
                sigma <- sig <- param$sigma
            }
            else if (length(param$sigma) != k & model == "BMM") {
                sigma <- lapply(1:k, function(x) {
                  runif(n = 1)
                })
                if (p != 1) {
                  sigma <- lapply(1:k, function(x) {
                    diag(p)
                  })
                }
            }
            else if (length(param$sigma) == k & class(param$sigma) != 
                "list") {
                sigma <- lapply(1:k, function(x) {
                  runif(n = 1)
                })
                if (p != 1) {
                  sigma <- lapply(1:k, function(x) {
                    diag(p)
                  })
                }
            }
            else if (model != "OUBMi" & model != "BMOUi" & model != 
                "OUEBi" & model != "EBOUi" & model != "BMEBi" & 
                model != "EBBMi" & model != "RR" & model != "RC") {
                sigma <- sig <- param$sigma
            }
            else {
                sigma <- param$sigma[[1]]
                sig <- param$sigma[[2]]
            }
        }
        if (model == "EC" || model == "RC" || model == "BMOU" || 
            model == "BMOUi") {
            before <- 2
            after <- 1
            if (model == "EC" || model == "BMOU") {
                model <- "ER"
            }
            else if (model == "RC" || model == "BMOUi") {
                model <- "RR"
            }
        }
        else if (model == "ER" || model == "RR" || model == "OUBM" || 
            model == "OUBMi") {
            before <- 1
            after <- 2
            if (model == "RR" || model == "OUBMi") {
                model <- "RR"
            }
            else if (model == "ER" || model == "OUBM") {
                model <- "ER"
            }
        }
        else if (model == "EBOU" || model == "EBOUi") {
            before <- 2
            after <- 1
            if (model == "EBOU") {
                model <- "OV"
            }
            else if (model == "EBOUi") {
                model <- "OVG"
            }
        }
        else if (model == "OUEB" || model == "OUEBi") {
            before <- 1
            after <- 2
            if (model == "OUEB") {
                model <- "OV"
            }
            else if (model == "OUEBi") {
                model <- "OVG"
            }
        }
        else if (model == "EBBM" || model == "EBBMi") {
            before <- 2
            after <- 1
            if (model == "EBBM") {
                model <- "CV"
            }
            else if (model == "EBBMi") {
                model <- "CVG"
            }
        }
        else if (model == "BMEB" || model == "BMEBi") {
            before <- 1
            after <- 2
            if (model == "BMEB") {
                model <- "CV"
            }
            else if (model == "BMEBi") {
                model <- "CVG"
            }
        }
        if (model == "RR" | model == "ER" | model == "OVG" | 
            model == "OV" | model == "CV" | model == "CVG") {
            if (!is.null(param[["age"]])) {
                tot <- max(nodeHeights(tree))
                limit = tot - param$age
                tree <- make.era.map(tree, c(0, limit))
            }
        }
        if (model == "OU1" | model == "OUM" | model == "RR" | 
            model == "ER" | model == "OVG" | model == "OV" | 
            model == "OUTS") {
            if (is.null(param[["alpha"]]) == TRUE) {
                alpha <- 1
                if (p != 1) {
                  alpha <- diag(p)
                }
                cat("No values provided for alpha, default value fixed to:", 
                  alpha, "\n")
            }
            else {
                alpha <- param$alpha
            }
        }
        if (model == "EB" | model == "CV" | model == "CVG" | 
            model == "OVG" | model == "OV") {
            if (is.null(param[["beta"]]) == TRUE) {
                beta <- 1
                cat("No values provided for beta, default value fixed to:", 
                  beta, "\n")
                if (p != 1) {
                  beta <- matrix(1, p, p)
                }
            }
            else {
                beta <- param$beta
                if (p != 1) {
                  beta <- matrix(param$beta, p, p)
                }
            }
        }
        if (is.null(param[["trend"]])) {
            istrend <- FALSE
        }
        else {
            istrend <- TRUE
            trend <- param$trend
            if (length(trend) < p) {
                stop("The number of specified values for the slopes of the trend do not match the number of traits!", 
                  "\n")
            }
        }
        if (model == "BMM") {
            sigmadim <- length(sigma[[1]])
        }
        else {
            sigmadim <- length(sigma)
        }
        if (sigmadim != p * p) {
            stop("The number of specified traits do not match the parameters matrix dimensions!", 
                "\n")
        }
    }
    if (root == "stationary") {
        mod_stand <- 1
    }
    else {
        mod_stand <- 0
    }
    if (inherits(tree, "phylo")) {
        if (model == "OUTS" | model == "RWTS") 
            stop("Error! you must provides a time-series, not a phylo object.")
        n <- length(tree$tip.label)
        if (model == "OU1" | model == "BM1" | model == "EB") {
            C <- vcv.phylo(tree)
        }
        else {
            C <- vcvSplit(tree)
        }
        names_rows <- tree$tip.label
    }
    else {
        tree <- tree - min(tree)
        C <- vcv.ts(tree)
        n <- length(tree)
        if (is.matrix(tree)) {
            names_rows <- rownames(tree)
        }
        else {
            names_rows <- names(tree)
        }
    }
    if (model == "OUM" | model == "OU1" | model == "OUTS") {
        if (is.null(param[["vcv"]])) {
            vcv <- param$vcv <- "randomRoot"
        }
        else {
            vcv <- param$vcv
        }
        if (model == "OUTS") {
            if (is.null(error) & vcv == "fixedRoot" | any(error[1, 
                ] == 0) & vcv == "fixedRoot") {
                warning("No sampling error provided for the initial observation(s) while using the \"fixedRoot\" parameterization.", 
                  "\n", "An arbitrary sampling error value is set to 0.01 for the initial observation(s) to avoid singularity issues. ")
                if (any(error[1, ] == 0) == TRUE) {
                  if (p == 1) {
                    error[1] <- 0.01
                  }
                  else {
                    error[1, ] <- 0.01
                  }
                }
                else {
                  error <- matrix(0, ncol = p, nrow = n)
                  error[1, ] <- 0.01
                }
            }
        }
    }
    if (model == "RWTS") {
        if (is.null(error) | any(error[1, ] == 0)) {
            warning("No sampling error provided for the initial observation(s).", 
                "\n", "An arbitrary sampling error value is set to 0.01 for the initial observation(s) to avoid singularity issues. ")
            if (any(error[1, ] == 0) == TRUE) {
                if (p == 1) {
                  error[1] <- 0.01
                }
                else {
                  error[1, ] <- 0.01
                }
            }
            else {
                error <- matrix(0, ncol = p, nrow = n)
                error[1, ] <- 0.01
            }
        }
    }
    if (!is.null(error)) {
        error <- as.vector(as.matrix(error))
        error[is.na(error)] <- 0
    }
    if (is.null(param[["method"]])) {
        methodSim <- "cholesky"
    }
    else {
        methodSim <- param$method
    }
    switch(model, RWTS = {
        param$smean <- TRUE
        W <- multD(tree, p, n, smean = param$smean)
        V <- .Call(kronecker_mvmorph, R = sigma, C = C, Rrows = as.integer(p), 
            Crows = as.integer(n))
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (istrend == TRUE) {
            Vdiag <- rep(diag(C), p)
            W <- W %*% as.numeric(mu) + Vdiag * (W %*% trend)
            mu <- as.numeric(1)
        }
    }, BM1 = {
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        if (istrend == FALSE & is.null(error) & p != 1 & param$smean) {
            Croot <- chol(C)
            W <- matrix(1, nrow = n, ncol = 1)
            if (nsim == 1 & p != 1) {
                X <- rmvnorm_simul(n = n, mean = rep(0, p), var = sigma, 
                  method = methodSim)
                deviates <- t(X %*% Croot)
                traits <- matrix(W %*% as.numeric(mu), ncol = p) + 
                  deviates
                rownames(traits) <- names_rows
                colnames(traits) <- names_traits
                return(traits)
            } else if (nsim > 1 & p != 1) {
                traits <- lapply(1:nsim, function(x) {
                  X <- rmvnorm_simul(n = n, mean = rep(0, p), 
                    var = sigma, method = methodSim)
                  deviates <- t(X %*% Croot)
                  traits <- matrix(W %*% as.numeric(mu), ncol = p) + 
                    deviates
                  rownames(traits) <- names_rows
                  colnames(traits) <- names_traits
                  traits
                })
                return(traits)
            }
        }
        W <- multD(tree, p, n, smean = param$smean)
        V <- .Call(kronecker_mvmorph, R = sigma, C = C, Rrows = as.integer(p), 
            Crows = as.integer(n))
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (istrend == TRUE) {
            Vdiag <- rep(diag(C), p)
            W <- W %*% as.numeric(mu) + Vdiag * (W %*% trend)
            mu <- as.numeric(1)
        }
    }, BMM = {
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        V <- .Call(kroneckerSum, R = sigma, C = C, Rrows = as.integer(p), 
            Crows = as.integer(n), dimlist = as.integer(k))
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (istrend == TRUE) {
            Vdiag <- rep(diag(Reduce("+", C)), p)
            W <- W %*% as.numeric(mu) + Vdiag * (W %*% trend)
            mu <- as.numeric(1)
        }
    }, OUTS = {
        eig <- eigen(alpha)
        svec <- try(solve(eig$vectors), silent = TRUE)
        if (inherits(svec, "try-error")) {
            warning("An error occured with the inverse of the orthogonal matrix, the \"pseudoinverse\" has been used instead")
            svec <- pseudoinverse(eig$vectors)
        }
        matdiag <- diag(p)
        if (vcv == "fixedRoot" | vcv == "univarpfFixed" | vcv == 
            "univarFixed" | vcv == "sparse") {
            V <- .Call(mvmorph_covar_mat, as.integer(n), bt = C, 
                lambda = eig$values, S = eig$vectors, sigmasq = sigma, 
                S1 = svec)
        } else if (vcv == "randomRoot" | vcv == "univarpfRandom" | 
            vcv == "univarRandom") {
            V <- .Call(simmap_covar, as.integer(n), bt = C, lambda = eig$values, 
                S = eig$vectors, S1 = svec, sigmasq = sigma)
        }
        if (root == TRUE) {
            W <- .Call(Weight_matrix, S1 = svec, S = eig$vectors, 
                lambda = eig$values, time = as.numeric(tree), 
                matdiag = as.numeric(matdiag))
        } else {
            W <- multD(NULL, p, n, smean = TRUE)
        }
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, OU1 = {
        param_ou <- mv.Precalc(tree, nb.traits = p, param = list(model = "OU1", 
            root = root))
        epochs <- param_ou$epochs
        listReg <- param_ou$listReg
        bt <- param_ou$C1
        eig <- eigen(alpha)
        svec <- try(solve(eig$vectors), silent = TRUE)
        if (inherits(svec, "try-error")) {
            warning("An error occured with the inverse of the orthogonal matrix, the \"pseudoinverse\" has been used instead")
            svec <- pseudoinverse(eig$vectors)
        }
        if (vcv == "fixedRoot" | vcv == "univarpfFixed" | vcv == 
            "univarFixed" | vcv == "sparse") {
            V <- .Call(mvmorph_covar_mat, as.integer(n), bt = bt, 
                lambda = eig$values, S = eig$vectors, sigmasq = sigma, 
                S1 = svec)
        } else if (vcv == "randomRoot" | vcv == "univarpfRandom" | 
            vcv == "univarRandom") {
            V <- .Call(simmap_covar, as.integer(n), bt = bt, 
                lambda = eig$values, S = eig$vectors, S1 = svec, 
                sigmasq = sigma)
        }
        W <- .Call(mvmorph_weights, nterm = as.integer(n), epochs = epochs, 
            lambda = eig$values, S = eig$vectors, S1 = svec, 
            beta = listReg, root = as.integer(mod_stand))
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, OUM = {
        param_ou <- mv.Precalc(tree, nb.traits = p, param = list(model = "OUM", 
            root = root))
        epochs <- param_ou$epochs
        listReg <- param_ou$listReg
        bt <- param_ou$C1
        eig <- eigen(alpha)
        svec <- try(solve(eig$vectors), silent = TRUE)
        if (inherits(svec, "try-error")) {
            warning("An error occured with the inverse of the orthogonal matrix, the \"pseudoinverse\" has been used instead")
            svec <- pseudoinverse(eig$vectors)
        }
        if (vcv == "fixedRoot" | vcv == "univarpfFixed" | vcv == 
            "univarFixed" | vcv == "sparse") {
            V <- .Call(mvmorph_covar_mat, as.integer(n), bt = bt, 
                lambda = eig$values, S = eig$vectors, sigmasq = sigma, 
                S1 = svec)
        } else if (vcv == "randomRoot" | vcv == "univarpfRandom" | 
            vcv == "univarRandom") {
            V <- .Call(simmap_covar, as.integer(n), bt = bt, 
                lambda = eig$values, S = eig$vectors, S1 = svec, 
                sigmasq = sigma)
        }
        W <- .Call(mvmorph_weights, nterm = as.integer(n), epochs = epochs, 
            lambda = eig$values, S = eig$vectors, S1 = svec, 
            beta = listReg, root = as.integer(mod_stand))
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, EB = {
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        V <- .Call(kroneckerEB, R = sigma, C = C, beta = beta, 
            Rrows = as.integer(p), Crows = as.integer(n))
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, RR = {
        if (p == 1) {
            Vou <- .Call(mvmorph_covar_ou_fixed, A = C[[before]], 
                alpha = alpha, sigma = sigma)
        } else {
            eig <- eigen(alpha)
            Vou <- .Call(mvmorph_covar_mat, nterm = as.integer(n), 
                bt = C[[before]], lambda = eig$values, S = eig$vectors, 
                sigmasq = sigma, S1 = solve(eig$vectors))
        }
        V <- .Call(kronecker_shift, R = sig, C = C[[after]], 
            Rrows = as.integer(p), Crows = as.integer(n), V = Vou)
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, ER = {
        if (p == 1) {
            Vou <- .Call(mvmorph_covar_ou_fixed, A = C[[before]], 
                alpha = alpha, sigma = sigma)
        } else {
            eig <- eigen(alpha)
            Vou <- .Call(mvmorph_covar_mat, nterm = as.integer(n), 
                bt = C[[before]], lambda = eig$values, S = eig$vectors, 
                sigmasq = sigma, S1 = solve(eig$vectors))
        }
        V <- .Call(kronecker_shift, R = sig, C = C[[after]], 
            Rrows = as.integer(p), Crows = as.integer(n), V = Vou)
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, CV = {
        V <- .Call(kronecker_shiftEB_BM, R1 = sig, R2 = sigma, 
            C1 = C[[before]], C2 = C[[after]], beta = alpha, 
            Rrows = as.integer(p), Crows = as.integer(n))
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, CVG = {
        V <- .Call(kronecker_shiftEB_BM, R1 = sig, R2 = sigma, 
            C1 = C[[before]], C2 = C[[after]], beta = alpha, 
            Rrows = as.integer(p), Crows = as.integer(n))
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, OV = {
        if (p == 1) {
            Vou <- .Call(mvmorph_covar_ou_fixed, A = C[[before]], 
                alpha = alpha, sigma = sigma)
        } else {
            eig <- eigen(alpha)
            Vou <- .Call(mvmorph_covar_mat, nterm = as.integer(n), 
                bt = C[[before]], lambda = eig$values, S = eig$vectors, 
                sigmasq = sigma, S1 = solve(eig$vectors))
        }
        V <- .Call(kronecker_shiftEB_OU, R = sig, C = C[[after]], 
            beta = beta, Rrows = as.integer(p), Crows = as.integer(n), 
            V = Vou)
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    }, OVG = {
        if (p == 1) {
            Vou <- .Call(mvmorph_covar_ou_fixed, A = C[[before]], 
                alpha = alpha, sigma = sigma)
        } else {
            eig <- eigen(alpha)
            Vou <- .Call(mvmorph_covar_mat, nterm = as.integer(n), 
                bt = C[[before]], lambda = eig$values, S = eig$vectors, 
                sigmasq = sigma, S1 = solve(eig$vectors))
        }
        V <- .Call(kronecker_shiftEB_OU, R = sig, C = C[[after]], 
            beta = beta, Rrows = as.integer(p), Crows = as.integer(n), 
            V = Vou)
        if (is.null(param[["smean"]]) == TRUE) {
            param$smean <- TRUE
        }
        W <- multD(tree, p, n, smean = param$smean)
        if (ncol(W) != length(mu)) stop("\n", "The number of parameters for theta is wrong", 
            "\n", ncol(W), " values are expected")
        if (is.null(error) == FALSE) {
            diag(V) <- diag(V) + error
        }
    })
    if (nsim == 1) {
        traits <- matrix(rmvnorm_simul(n = 1, as.numeric(W %*% 
            as.numeric(mu)), V, methodSim), ncol = p)
        rownames(traits) <- names_rows
        colnames(traits) <- names_traits
    }
    else if (nsim > 1 & p != 1) {
        traits <- lapply(1:nsim, function(x) {
            traits <- matrix(rmvnorm_simul(n = 1, as.numeric(W %*% 
                as.numeric(mu)), V, methodSim), ncol = p)
            rownames(traits) <- names_rows
            colnames(traits) <- names_traits
            traits
        })
    }
    else {
        traits <- matrix(rmvnorm_simul(n = nsim, as.numeric(W %*% 
            as.numeric(mu)), V, methodSim), ncol = nsim)
        rownames(traits) <- names_rows
    }
    return(traits)
}
<bytecode: 0x9922380>
<environment: namespace:mvMORPH>
 --- function search by body ---
Function mvSIM in namespace mvMORPH has this body.
 ----------- END OF FAILURE REPORT -------------- 
Quitting from lines 65-74 (tutorial_mvMORPH.Rmd) 
Error: processing vignette 'tutorial_mvMORPH.Rmd' failed with diagnostics:
the condition has length > 1
--- failed re-building 'tutorial_mvMORPH.Rmd'

SUMMARY: processing the following files failed:
  'How_to_use_mvMORPH.Rmd' 'tutorial_mvMORPH.Rmd'

Error: Vignette re-building failed.
Execution halted