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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: cvmsma
> ### Title: Cross-Validation
> ### Aliases: cvmsma
> 
> ### ** Examples
> 
> ##### data #####
> tmpdata = simdata(n = 50, rho = 0.8, Yps = c(10, 12, 15), Xps = 20, seed=1)
> X = tmpdata$X; Y = tmpdata$Y 
> 
> ##### One Component CV #####
> cv1 = cvmsma(X, Y, comp = 1, lambdaX=2, lambdaY=1:3, nfold=5, seed=1)
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
msma
 --- call from context --- 
project(X[[x]], sbX[[x]])
 --- call from argument --- 
while (judge) {
    invcrossy = try(solve(crossy + 1e-18 * 10^i * diag(ncol(crossy))), 
        silent = TRUE)
    judge = (class(invcrossy) == "try-error")
    i = i + 1
}
 --- R stacktrace ---
where 1: project(X[[x]], sbX[[x]])
where 2: FUN(X[[i]], ...)
where 3: lapply(1:Xnb, function(x) sbX[[x]] %*% project(X[[x]], sbX[[x]]))
where 4: msma.default(tmpX, tmpY, tmpZ, comp, lambdaX = lambdaX, lambdaY = lambdaY, 
    lambdaXsup = lambdaXsup, lambdaYsup = lambdaYsup, eta, type, 
    inX = inX, inY = inY, inXsup = inXsup, inYsup = inYsup, muX = muX, 
    muY = muY)
where 5: msma(tmpX, tmpY, tmpZ, comp, lambdaX = lambdaX, lambdaY = lambdaY, 
    lambdaXsup = lambdaXsup, lambdaYsup = lambdaYsup, eta, type, 
    inX = inX, inY = inY, inXsup = inXsup, inYsup = inYsup, muX = muX, 
    muY = muY)
where 6: FUN(X[[i]], ...)
where 7: lapply(X = X, FUN = FUN, ...)
where 8: sapply(1:nfold, function(i) {
    tmpX = lapply(X, function(tmpset) tmpset[!(fold == i), ])
    testX = lapply(X, function(testset) testset[(fold == i), 
        ])
    if (dmode == "PCA") {
        tmpY = testY = NULL
    }
    else {
        tmpY = lapply(Y, function(tmpset) tmpset[!(fold == i), 
            ])
        testY = lapply(Y, function(testset) testset[(fold == 
            i), ])
    }
    if (is.null(Z)) {
        tmpZ = testZ = NULL
    }
    else {
        if (class(Z) != "matrix") 
            dim(Z) = c(length(Z), 1)
        tmpZ = Z[!(fold == i), ]
        testZ = Z[(fold == i), ]
    }
    fit = msma(tmpX, tmpY, tmpZ, comp, lambdaX = lambdaX, lambdaY = lambdaY, 
        lambdaXsup = lambdaXsup, lambdaYsup = lambdaYsup, eta, 
        type, inX = inX, inY = inY, inXsup = inXsup, inYsup = inYsup, 
        muX = muX, muY = muY)
    test = predict(fit, newX = testX, newY = testY)
    testX = lapply(1:length(testX), function(x) scale(testX[[x]], 
        center = fit$Xscale[[x]]$`scaled:center`))
    Xerr = matserr(testX, test$X)
    out = Xerr
    if (dmode == "PLS") {
        testY = lapply(1:length(testY), function(x) scale(testY[[x]], 
            center = fit$Yscale[[x]]$`scaled:center`, scale = fit$Yscale[[x]]$`scaled:scale`))
        testY = lapply(1:length(testY), function(x) scale(testY[[x]], 
            center = fit$Yscale[[x]]$`scaled:center`))
        Yerr = matserr(testY, test$Y)
        out = c(mean(c(Xerr, Yerr)), Xerr, Yerr)
    }
    out
})
where 9: cvmsma(X, Y, comp = 1, lambdaX = 2, lambdaY = 1:3, nfold = 5, 
    seed = 1)

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (x, y) 
{
    if (is.null(ncol(y))) {
        c(x %*% cbind(y)/drop(crossprod(y)))
    }
    else {
        crossy = t(y) %*% y
        i = 0
        judge = TRUE
        while (judge) {
            invcrossy = try(solve(crossy + 1e-18 * 10^i * diag(ncol(crossy))), 
                silent = TRUE)
            judge = (class(invcrossy) == "try-error")
            i = i + 1
        }
        invcrossy %*% t(y) %*% x
    }
}
<bytecode: 0x55be2dbc35c8>
<environment: namespace:msma>
 --- function search by body ---
Function project in namespace msma has this body.
 ----------- END OF FAILURE REPORT -------------- 
Error in while (judge) { : the condition has length > 1
Calls: cvmsma ... FUN -> msma -> msma.default -> lapply -> FUN -> project
Execution halted