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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: estimate_slopes
> ### Title: Estimate Marginal Effects
> ### Aliases: estimate_slopes
> 
> ### ** Examples
> 
> ## Don't show: 
> if (require("emmeans") && require("ggplot2") && require("see")) (if (getRversion() >= "3.4") withAutoprint else force)({ # examplesIf
+ ## End(Don't show)
+ # Get an idea of the data
+ 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)
+ 
+ # 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
+ 
+ # Plot it
+ plot(slopes)
+ 
+ standardize(slopes)
+ ## Don't show: 
+ }) # examplesIf
Loading required package: emmeans
Welcome to emmeans.
Caution: You lose important information if you filter this package's results.
See '? untidy'
Loading required package: ggplot2
Loading required package: see
> 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)
`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 <- lm(Sepal.Width ~ Species * Petal.Length, data = iris)
> slopes <- estimate_slopes(model, trend = "Petal.Length", at = "Species")
Warning: Argument `at` is deprecated and will be removed in a future release.
  Please use `by` instead.
> 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> ## End(Don't show)
> ## Don't show: 
> if (require("mgcv") && require("emmeans") && require("see")) (if (getRversion() >= "3.4") withAutoprint else force)({ # examplesIf
+ ## End(Don't show)
+ 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)
+ ## Don't show: 
+ }) # examplesIf
Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.9-1. For overview type 'help("mgcv-package")'.
> model <- mgcv::gam(Sepal.Width ~ s(Petal.Length), data = iris)
> slopes <- estimate_slopes(model, at = "Petal.Length", length = 50)
No numeric variable was specified for slope estimation. Selecting `trend = "Petal.Length"`.
Warning: Argument `at` is deprecated and will be removed in a future release.
  Please use `by` instead.
> summary(slopes)
Killed