Closed Jendryczko closed 1 month ago
I've been unable to replicate this, so I'm fairly puzzled. Can you (and any others experiencing the error) give the full output of sessionInfo()
?
Thank you for attending to this problem. Here you go:
library(interactions)
fiti <- lm(Income ~ Frost + Murder * Illiteracy, data=as.data.frame(state.x77)) probe_interaction(model = fiti, pred = Murder, modx = Illiteracy, modx.values = "plus-minus") # sessionInfo()
Output:
Error:
! class
must be a character vector, not a list.
Backtrace:
<fn>
(class = # sessionInfo() R version 4.2.2 (2022-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale: [1] LC_COLLATE=German_Germany.utf8 LC_CTYPE=German_Germany.utf8 LC_MONETARY=German_Germany.utf8 [4] LC_NUMERIC=C LC_TIME=German_Germany.utf8
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] interactions_1.1.5
loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 rstudioapi_0.14 magrittr_2.0.3 tidyselect_1.2.0 munsell_0.5.0 colorspace_2.0-3
[7] R6_2.5.1 rlang_1.0.6 fansi_1.0.3 dplyr_1.0.10 tools_4.2.2 grid_4.2.2
[13] gtable_0.3.1 utf8_1.2.2 cli_3.5.0 DBI_1.1.3 digest_0.6.31 assertthat_0.2.1
[19] tibble_3.1.8 lifecycle_1.0.3 crayon_1.5.2 ggplot2_3.4.0 vctrs_0.5.1 jtools_2.2.1
[25] glue_1.6.2 compiler_4.2.2 pander_0.6.5 pillar_1.8.1 generics_0.1.3 scales_1.2.1
[31] pkgconfig_2.0.3
The problem only occurs if the sandwich
package is not installed. Thus, @Jendryczko, a quick fix is to install the sandwich
package.
What happens internally is the following:
sim_slopes()
calls get_robust_se()
get_robust_se()
checks whether the sandwich
package is availablesandwich
is needed via: stop_wrap("When using robust SEs you need to have the \'sandwich\' package.", call. = FALSE)
.call. = FALSE
argument is not caught by jtools::stop_wrap()
but passed on to rlang
which then failsMy guess is that jtools::stop_wrap()
needs to handle the class. = FALSE
argument correctly , similar to jtools::warn_wrap()
. Or possibly the stop_wrap()
calls in the packages need to be fixed. @jacob-long, it would be great if you could have a look at this.
Thank you very much @zeileis. You were right, simply installing the sandwich-package (no need to load it with library()) fixed everything. I could swear that when I installed ineractions in older R-versions, sandwich was automatically installed alongside but I may be remembering that wrong.
Possibly you indicated that you want all dependencies to be installed (and not just the required Depends/Imports). The sandwich package is only a "Suggests" and not an "Imports" dependency.
Thank you so much :)
Hello everybody.
I already reported this problem to r-lib/rlang: https://github.com/r-lib/rlang/issues/1529
but I was asked to report it here, so I repeat it:
It seems that there is some sort of compatability issue with the latest version of the interactions-package with the latest version of the rlang-package, and -potentially - also the latest version of R and RStudio. If I run the first example provided for "sim_slopes":
fiti <- lm(Income ~ Frost + Murder * Illiteracy, data = as.data.frame(state.x77)) sim_slopes(model = fiti, pred = Murder, modx = Illiteracy)
I get the following error: Error: ! class must be a character vector, not a list. Backtrace:
versions: packageVersion('interactions')# ‘1.1.5' packageVersion('rlang')# ‘1.0.6’ packageVersion('jtools')# 2.2.1
R-version: 4.2.2.
RStudio-version: 2022.07.2 Build 576
There already exists a stackoverflow entry for this: https://stackoverflow.com/questions/74720514/interactions-and-rlang-error-class-must-be-a-character-vector-not-a-list
But updating the dependencies for jtools and rlang did not help in my case. Does anybody have any solutions?