Closed b1azk0 closed 4 years ago
Could you show me the code before this that you used to create the mediation model?
Just FYI I prepared an .Rmd file on my work laptop no problem, but then when I tried to knit it on my home computer, I started getting this error (both computers are on Windows 10). But not when ran locally in the console, only when knitted. Replicated in both R 4.2.3 and 4.3.0.
The script is available here in case you want to try to replicate it. But you might not be able to, as I was saying it was working no problem on my laptop. For reference, here's my session info for the problematic computer:
<sup>Created on 2023-05-22 with [reprex v2.0.2](https://reprex.tidyverse.org)</sup>
Interestingly, I am able to reproduce the problem in a reprex:
packageVersion("lavaanPlot")
#> [1] '0.6.2'
packageVersion("lavaan")
#> [1] '0.6.15'
packageVersion("DiagrammeR")
#> [1] ‘1.0.10’
library(lavaan)
#> This is lavaan 0.6-15
#> lavaan is FREE software! Please report any bugs.
mod <- "x1 ~ x2"
fit <- sem(mod, data = HolzingerSwineford1939)
lavaanPlot::lavaanPlot(fit)
#> Error in as.character.default(new("lavaan", version = "0.6.15", call = lavaan::lavaan(model = mod, : no method for coercing this S4 class to a vector
Created on 2023-05-20 with reprex v2.0.2
Seems like I'm not the only one with this issue. See the first comments in this 2022 and 2021 stackoverflow answers. The error seems difficult to pinpoint however, I've tried regressing several packages (lavaanPlot, lavaan, DiagrammeR), R versions, updating all packages, and all MiKTeX packages. Nothing has worked so far. Seems like a bug with the computer itself?
For reference, session info on the working computer:
packageVersion("lavaanPlot")
#> [1] '0.6.3'
packageVersion("lavaan")
#> [1] '0.6.15'
packageVersion("DiagrammeR")
#> [1] '1.0.9'
library(lavaan)
mod <- "x1 ~ x2"
fit <- sem(mod, data = HolzingerSwineford1939)
lavaanPlot::lavaanPlot(fit)
<sup>Created on 2023-05-22 with [reprex v2.0.2](https://reprex.tidyverse.org)</sup>
Upgrading lavaanPlot
to the development version, and knitr
and igraph
to the latest CRAN versions fixed this issue on the problematic computer 👌
Each time I try to plot my mediation model I get this error: