Closed HPDell closed 2 years ago
But everything goes well when the function is called in this way:
HLM_summary(formula = model.hlm.formula, data = mydata)
Hello. Please provide all code relevant to this issue. It seems like something invalid in the R formula when building the model using lmer()
.
Please see this example:
library(bruceR)
library(lmerTest)
m1=lmer(Reaction ~ Days + (Days | Subject), data=sleepstudy)
HLM_summary(m1) # OK
formula=Reaction ~ Days + (Days | Subject)
m2=lmer(formula, data=sleepstudy)
HLM_summary(m2) # Error
# Error in formula[[2]] : object of type 'symbol' is not subsettable
HLM_summary(formula=formula, data=sleepstudy) # OK
To use a variable like model.hlm.formula
to define a formula and pass it to lmer()
(e.g., lmer(model.hlm.formula, data=mydata)
), please use the argument formula
of HLM_summary()
. By default, HLM_summary()
extracts formula=model[["call"]][["formula"]]
and its second element formula[[2]]
is the outcome variable. If you use a variable rather than a formula in lmer()
, it definitely extracts nothing.
The latest commit to GitHub has addressed this issue (now the function extracts the name of outcome variable from the data frame of the model rather than from its formula call). I close this issue.
Thanks. I wrote my code in the way that is almost exactly shown in your example. However, once I found the possible cause, I've reformated my code to get over this problem. Sorry that I forgot to provide more information when opening this issue.
P.S. A brilliant package! I like it very much.
Platform: Windows x64
R Version: 4.1.1 (x64)
bruceR Version: latest (installed via
install_github()
)When I tried to generate tidy report of an object returned from function
lmer()
, the following error occurred: