[Rd] Error in R CMD check --as-cran ?

Therneau, Terry M., Ph.D. therne@u @end|ng |rom m@yo@edu
Mon Jan 13 17:28:32 CET 2020


I've been fighting a CMD check error for coxme this morning.   I thought I had it fixed, 
but instead I had forgotton --as-cran on my last test run.  So the version just submitted 
to CRAN has warning messages in the log.

I think it is an issue with CRAN.   I've sent a message to R-devel asking for help.   
Since then, as a guess, I renamed my internal "ismat" function to something else and the 
error went away.

Here is the code block in coxme,  it is part of the "check user arguments for validity" 
block at the start of the function.   Run coxme in a terminal and all is well, run R CMD 
check without as-cran and all is well, but with --as-cran the ismat function gives 
warnings.  Changing the name to something else fixes the issue.   The function exists only 
to save some typing.  (No need to really read the block, just notice the multiple calls to 
ismat()

     ismat <- function (x) {
         inherits(x, c("matrix", "bdsmatrix", "Matrix"), which=FALSE)
     }
     if (missing(varlist) || is.null(varlist)) {
         varlist <- vector('list', nrandom)
         for (i in 1:nrandom) varlist[[i]] <- coxmeFull() #default
     }
     else {
         if (is.function(varlist)) varlist <- varlist()
         if (inherits(varlist, 'coxmevar')) varlist <- list(varlist)
         else if (ismat(varlist))
             varlist <- list(coxmeMlist(list(varlist)))
         else {
             if (!is.list(varlist)) stop("Invalid varlist argument")
             if (all(sapply(varlist, ismat))) {
                 # A list of matrices
                 if (nrandom >1)
                     stop(paste("An unlabeled list of matrices is",
                                "ambiguous when there are multiple random terms"))
                 else varlist <- list(coxmeMlist(varlist))
             }
             else {  #the user gave me a list, not all matrices
                 for (i in 1:length(varlist)) {
                     if (is.function(varlist[[i]]))
                         varlist[[i]] <-varlist[[i]]()
                     if (ismat(varlist[[i]]))
                         varlist[[i]] <- coxmeMlist(list(varlist[[i]]))
                     if (class(varlist[[i]]) != 'coxmevar') {
                         if (is.list(varlist[[i]])) {
                             if (all(sapply(varlist[[i]], ismat)))
                                 varlist[[i]] <- coxmeMlist(varlist[[i]])
                             else stop("Invalid varlist element")
                         }
                         else stop("Invalid varlist element")
                     }
                 }
             }
         }
         while(length(varlist) < nrandom) varlist <- c(varlist, list(coxmeFull()))
     }


	[[alternative HTML version deleted]]



More information about the R-devel mailing list