Running examples in 'modelbased-Ex.R' failed
The error most likely occurred in:

> ### Name: estimate_slopes
> ### Title: Estimate Marginal Effects
> ### Aliases: estimate_slopes
> 
> ### ** Examples
> 
> 
> # Get an idea of the data
> if (require("ggplot2")) {
+   ggplot(iris, aes(x = Petal.Length, y = Sepal.Width)) +
+     geom_point(aes(color = Species)) +
+     geom_smooth(color = "black", se = FALSE) +
+     geom_smooth(aes(color = Species), linetype = "dotted", se = FALSE) +
+     geom_smooth(aes(color = Species), method = "lm", se = FALSE)
+ }
Loading required package: ggplot2
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
> 
> # Model it
> model <- lm(Sepal.Width ~ Species * Petal.Length, data = iris)
> # Compute the marginal effect of Petal.Length at each level of Species
> slopes <- estimate_slopes(model, trend = "Petal.Length", at = "Species")
> slopes
Estimated Marginal Effects

Species    | Coefficient |   SE |        95% CI | t(144) |      p
-----------------------------------------------------------------
setosa     |        0.39 | 0.26 | [-0.13, 0.90] |   1.49 | 0.138 
versicolor |        0.37 | 0.10 | [ 0.18, 0.56] |   3.89 | < .001
virginica  |        0.23 | 0.08 | [ 0.07, 0.40] |   2.86 | 0.005 
Marginal effects estimated for Petal.Length> plot(slopes)
> standardize(slopes)
Estimated Marginal Effects (standardized)

Species    | Coefficient |   SE |        95% CI | t(144) |      p
-----------------------------------------------------------------
setosa     |        0.89 | 0.60 | [-0.29, 2.07] |   1.49 | 0.138 
versicolor |        0.86 | 0.22 | [ 0.42, 1.29] |   3.89 | < .001
virginica  |        0.54 | 0.19 | [ 0.17, 0.91] |   2.86 | 0.005 
Marginal effects estimated for Petal.Length> 
> if (require("mgcv")) {
+   model <- mgcv::gam(Sepal.Width ~ s(Petal.Length), data = iris)
+   slopes <- estimate_slopes(model, at = "Petal.Length", length = 50)
+   summary(slopes)
+   plot(slopes)
+ 
+   model <- mgcv::gam(Sepal.Width ~ s(Petal.Length, by = Species), data = iris)
+   slopes <- estimate_slopes(model,
+     trend = "Petal.Length",
+     at = c("Petal.Length", "Species"), length = 20
+   )
+   summary(slopes)
+   plot(slopes)
+ }
Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-39. For overview type 'help("mgcv-package")'.
No numeric variable was specified for slope estimation. Selecting `trend = "Petal.Length"`.
Error in xj[i] : invalid subscript type 'list'
Calls: summary -> summary.estimate_slopes -> [ -> [.data.frame
Execution halted