I am relatively new to R. I am trying to run an MLM model using the lme4 and brms packages, however when I load in the packages, I am informed the matrix package (which is required) is missing from lme4 and brms.
> library(lme4)
Error: package ‘Matrix’ required by ‘lme4’ could not be found
> library(brms)
Error: package or namespace load failed for ‘brms’ in loadNamespace(j <- imp[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘Matrix`
I did some research and found this post: “Error in initializePtr() : function ‘cholmod_factor_ldetA’ not provided by package ‘Matrix'” when using lmer function in R
It provided the code below which I ran:
oo <- options(repos = "https://cran.r-project.org/")
utils::install.packages("Matrix")
utils::install.packages("lme4")
options(oo)
and still the “Matrix” package was not installed as per the message below
oo <- options(repos = “https://cran.r-project.org/”)
utils::install.packages(“Matrix”)`
Warning message:
package ‘Matrix’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
utils::install.packages(“lme4”)
Warning: dependency ‘Matrix’ is not available
trying URL ‘https://cran.r-project.org/bin/macosx/big-sur-arm64/contrib/4.3/lme4_1.1-35.3.tgz’
Content type ‘application/x-gzip’ length 7073031 bytes (6.7 MB)
==================================================
downloaded 6.7 MB
The downloaded binary packages are in
/var/folders/91/614smq9x69331t5dqfx6w1nc0000gp/T//Rtmpo0EtW6/downloaded_packages`
How do I ensure the matrix package is installed with lme4 and brms? Any insights would be greatly be appreciated! Thanks!
Stats84 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.