简体   繁体   中英

Error: “could not find function ”lengths"

While running:

 reg_model = glmer(modeling1 ~ pTOT_VIOPT_CT + (1|STUDY_CODE_ALIAS),
                  data=data_CACZ, family=binomial)

I am getting the error:

Error in .fixupDimnames(.Object@Dimnames) : 
  could not find function "lengths"

Not sure what could be the possible reason.

FYI: I am putting below the sessionInfo() :

R version 3.0.2 (2013-09-25)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Rcpp_0.11.5  lme4_1.1-10  Matrix_1.2-3 car_2.0-21   MASS_7.3-29 

loaded via a namespace (and not attached):
[1] grid_3.0.2      lattice_0.20-29 minqa_1.2.4     nlme_3.1-118    nloptr_1.0.4    nnet_7.3-7      splines_3.0.2   tools_3.0.2   

(From the maintainer of 'Matrix'): This is indeed really strange, but differently than @nicola suggests.

  1. It is okay to update Recommended packages such as Matrix without updating R. That's indeed one feature of these.
  2. Matrix 1.2-3 is indeed the current version of Matrix on CRAN, which is good.

However, since Matrix 1.2-2, there is the following code in Matrix/R/zzz.R :

if(getRversion() >= "3.2.0") {
    ......
} else {
    ......
    lengths <- function (x, use.names = TRUE) vapply(x, length, 1L, USE.NAMES = use.names)
}

But that code only works correctly for you, when the Matrix package is built from the source with a correct version of R, ie in your case with a version of R before 3.2.0. This (correctly built) happens for all platforms but Windows (the broken by choice one).

If you really don't want (or can't easily) upgrade your version of R, you have two other options:

  1. downgrade your version of Matrix to the one that comes with your version of R. As you probably have installed the new Matrix replacing the old one, you need to get that and replace the newer version of Matrix. HOWEVER, I guess you would also have to downgrade lme4, and in the end you suffer too much.
  2. Safer and in principle correct: Install the 'Rtools' collection for Windows (you need the one that matches your version of R !) including C compiler etc, until the following works correctly

     install.packages("Matrix", type = "source") 

The work to do this may well be worth it. You will be able to install other R packages from their source, which is very useful anyway (I would not want to live without this possibility if I had to work with Windows).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM