Error in loading "lme4" and "Matrix" packages to create a generalized linear mixed-effects model

Hello! I am having trouble with creating a generalized linear mixed-effects model using the "lme4" package. Bear with me - I'm a new RStudio user and a first time poster.

This is the error I'm receiving:

*Error in initializePtr() : *

  • function 'cholmod_factor_ldetA' not provided by package 'Matrix'*

This is what my code currently looks like:

install.packages("readr")
library(readr)
install.packages("tidyverse")
library(tidyverse)
install.packages("ggplot2")
library(ggplot2)
install.packages("lme4")
library(lme4)

tools::package_dependencies("Matrix", which = "LinkingTo", reverse = TRUE)[[1L]]
install.packages("lme4", type = "source")
library (lme4)
library (Matrix)

beehavior <- read.csv("beehaviorln3.csv", header=TRUE)
View(beehavior)

linht <- glmer(LnHandling ~ Genus + Flower + (1|Site), family = poisson, data = beehavior)
summary(linht)

I have tried beginning again in a new session, uninstalling and re-installing packages, changing how I install "lme4" and everything I can think of. Another forum I found said to try installing it from the source, which is where that code came from. It looks like I have an up-to-date version of the package. Does anyone have suggestions on things I can try? Thank you.

I gave your code a try (substituting the "iris" database for your data and tweaking the model formula somewhat whimsically) and got a different but similar message regarding a function not provided by Matrix. I then followed the instructions from the top answer here, specifically the bit about forcing R to use the CRAN repository to reinstall both Matrix and lme:

oo <- options(repos = "https://cran.r-project.org/")
install.packages("Matrix")
install.packages("lme4")
options(oo)

After restarting the R session (from within RStudio), I reran the code and it appeared to work (albeit with 50 or so unprinted warnings -- but at least it created the model).

This is an incompatibility in Matrix, if I remember correctly, and the solution is indeed to reinstall packages in the right order: [R-pkg-devel] Note to repository maintainers about ABI change in Matrix 1.6-2

Thank you so much for your help! I didn't get the error this time and I think it ran, but I also got the 50+ warning messages (seemingly because none of my x-values are integers). I also did not get the summary when I ran the "summary(linht)" line - nothing came up. Do you know why this may be?

I think it's due to the non-integer data. I hit the same thing using the iris data set. Then I rounded the four measurement columns to integer values and reran the fit. There was a warning about a singular fit, but summary displayed.

You should probably look into whether the model you are using is appropriate for your data.