Running examples in 'autoFRK-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: autoFRK
> ### Title: Automatic Fixed Rank Kriging
> ### Aliases: autoFRK
> 
> ### ** Examples
> 
> #### generating data from two eigenfunctions
> set.seed(0)
> n=150
> s=5
> grid1=grid2=seq(0,1,l=30)
> grids=expand.grid(grid1,grid2)
> fn=matrix(0,900,2)
> fn[,1]=cos(sqrt((grids[,1]-0)^2+(grids[,2]-1)^2)*pi)
> fn[,2]=cos(sqrt((grids[,1]-0.75)^2+(grids[,2]-0.25)^2)*2*pi)
> 
> #### single realization simulation example
> w=c(rnorm(1,sd=5),rnorm(1,sd=3))
> y=fn%*%w
> obs=sample(900,n)
> z=y[obs]+rnorm(n)*sqrt(s)
> X=grids[obs,]
> 
> #### method1: automatic selection and prediction
> one.imat=autoFRK(Data=z,loc=X,maxK=15)  
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
autoFRK
 --- call from context --- 
basisSelect(Data, loc, D, maxit, tolerance, maxK, Kseq, method, 
    n.neighbor, maxknot, NULL)
 --- call from argument --- 
if (class(Data) == "numeric") Data = as.matrix(Data)
 --- R stacktrace ---
where 1: basisSelect(Data, loc, D, maxit, tolerance, maxK, Kseq, method, 
    n.neighbor, maxknot, NULL)
where 2: autoFRK(Data = z, loc = X, maxK = 15)

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (Data, loc, D = diag.spam(NROW(Data)), maxit = 50, avgtol = 0.1^6, 
    maxK = NULL, Kseq = NULL, method = c("fast", "EM"), n.neighbor = 3, 
    maxknot = 5000, DfromLK = NULL, Fk = NULL) 
{
    Data = as.matrix(Data)
    empty = apply(!is.na(Data), 2, sum) == 0
    if (sum(empty) > 0) 
        Data = Data[, which(!empty)]
    if (class(Data) == "numeric") 
        Data = as.matrix(Data)
    loc = as.matrix(loc)
    d = NCOL(loc)
    withNA = sum(is.na(Data)) > 0
    del = which(rowSums(as.matrix(!is.na(Data))) == 0)
    pick = 1:NROW(Data)
    if (length(del) > 0) {
        Data = Data[-del, ]
        D = D[-del, -del]
        pick = pick[-del]
        withNA = sum(is.na(Data)) > 0
    }
    N = length(pick)
    klim = min(N, round(10 * sqrt(N)))
    if (N < maxknot) 
        knot = loc[pick, ]
    else knot = subknot(loc[pick, ], min(maxknot, klim))
    if (!is.null(maxK)) 
        maxK = round(maxK)
    else {
        if (!is.null(Kseq)) 
            maxK = round(max(Kseq))
        else maxK = klim
    }
    if (!is.null(Kseq)) {
        K = unique(round(Kseq))
        if (max(K) > maxK) 
            stop("maximum of Kseq is larger than maxK!")
        if (any(K < (d + 1))) 
            warning("The minimum of Kseq can not less than ", 
                d + 1, ". Too small values will be ignored.")
        K = K[K > d]
        if (length(K) == 0) 
            stop("Not valid Kseq!")
    }
    else {
        K = unique(round(seq(d + 1, maxK, by = maxK^(1/3) * d)))
        if (length(K) > 30) 
            K = unique(round(seq(d + 1, maxK, l = 30)))
    }
    if (is.null(Fk)) 
        Fk = mrts(knot, max(K), loc)
    AIClist = rep(Inf, length(K))
    method = match.arg(method)
    if ((method == "EM") & (is.null(DfromLK))) {
        for (k in 1:length(K)) AIClist[k] = indeMLE(Data, Fk[pick, 
            1:K[k]], D, maxit, avgtol, wSave = FALSE, num.report = FALSE)$negloglik
    }
    else {
        if (withNA) {
            Data = as.matrix(Data)
            for (tt in 1:NCOL(Data)) {
                where = is.na(Data[, tt])
                if (sum(where) == 0) 
                  next
                cidx = which(!where)
                nnidx = FNN::get.knnx(loc[cidx, ], as.matrix(loc[where, 
                  ]), k = n.neighbor)
                nnidx = array(cidx[nnidx$nn.index], dim(nnidx$nn.index))
                nnval = array((Data[, tt])[nnidx], dim(nnidx))
                Data[where, tt] = rowMeans(nnval)
            }
        }
        TT = NCOL(Data)
        if (is.null(DfromLK)) {
            iD = solve(D)
            iDFk = iD %*% Fk[pick, ]
            iDZ = iD %*% Data
        }
        else {
            wX = DfromLK$wX[pick, ]
            G = t(DfromLK$wX) %*% DfromLK$wX + DfromLK$lambda * 
                DfromLK$Q
            weight = DfromLK$weights[pick]
            wwX = diag.spam(sqrt(weight)) %*% wX
            wXiG = (wwX) %*% solve(G)
            iDFk = weight * Fk[pick, ] - wXiG %*% (t(wwX) %*% 
                as.matrix(Fk[pick, ]))
            iDZ = weight * Data - wXiG %*% (t(wwX) %*% as.matrix(Data))
        }
        trS = sum(rowSums(as.matrix(iDZ) * Data))/TT
        for (k in 1:length(K)) {
            half = getHalf(Fk[pick, 1:K[k]], iDFk[, 1:K[k]])
            ihFiD = half %*% t(iDFk[, 1:K[k]])
            JSJ = tcrossprod(ihFiD %*% Data)/TT
            JSJ = (JSJ + t(JSJ))/2
            AIClist[k] = cMLE(Fk[pick, 1:K[k]], TT, trS, half, 
                JSJ, s = 0)$negloglik
        }
    }
    TT = NCOL(Data)
    df = (K * (K + 1)/2 + 1) * (K <= TT) + (K * TT + 1 - TT * 
        (TT - 1)/2) * (K > TT)
    AIClist = AIClist + 2 * df
    Kopt = K[which.min(AIClist)]
    out = Fk[, 1:Kopt]
    dimnames(Fk) = NULL
    aname = names(attributes(Fk))
    attributes(out) = c(attributes(out), attributes(Fk)[setdiff(aname, 
        "dim")])
    return(out)
}
<bytecode: 0x725fed8>
<environment: namespace:autoFRK>
 --- function search by body ---
Function basisSelect in namespace autoFRK has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1