diff --git a/R/visualisation_recipe.estimate_means.R b/R/visualisation_recipe.estimate_means.R index c062f32fe..9a99ba43d 100644 --- a/R/visualisation_recipe.estimate_means.R +++ b/R/visualisation_recipe.estimate_means.R @@ -23,11 +23,11 @@ #' data$new_factor <- as.factor(rep(c("A", "B"), length.out = nrow(mtcars))) #' #' model <- lm(mpg ~ new_factor * cyl * wt, data = data) -#' x <- estimate_means(model, by =c("new_factor", "cyl")) +#' x <- estimate_means(model, by = c("new_factor", "cyl")) #' plot(visualisation_recipe(x)) #' #' # Modulations -------------- -#' x <- estimate_means(model, by =c("new_factor", "wt")) +#' x <- estimate_means(model, by = c("new_factor", "wt")) #' plot(visualisation_recipe(x)) #' #' # x <- estimate_means(model, by =c("new_factor", "cyl", "wt")) diff --git a/R/visualisation_recipe.estimate_slopes.R b/R/visualisation_recipe.estimate_slopes.R index 0f03bc614..f801a5260 100644 --- a/R/visualisation_recipe.estimate_slopes.R +++ b/R/visualisation_recipe.estimate_slopes.R @@ -6,18 +6,18 @@ #' # ============================================== #' if (require("ggplot2")) { #' model <- lm(Sepal.Width ~ Species * Petal.Length, data = iris) -#' x <- estimate_slopes(model, trend = "Petal.Length", by ="Species") +#' x <- estimate_slopes(model, trend = "Petal.Length", by = "Species") #' #' layers <- visualisation_recipe(x) #' layers #' plot(layers) #' #' model <- lm(Petal.Length ~ poly(Sepal.Width, 4), data = iris) -#' x <- estimate_slopes(model, by ="Sepal.Width", length = 20) +#' x <- estimate_slopes(model, by = "Sepal.Width", length = 20) #' plot(visualisation_recipe(x)) #' #' model <- lm(Petal.Length ~ Species * poly(Sepal.Width, 3), data = iris) -#' x <- estimate_slopes(model, by =c("Sepal.Width", "Species")) +#' x <- estimate_slopes(model, by = c("Sepal.Width", "Species")) #' plot(visualisation_recipe(x)) #' } #' \donttest{ @@ -27,11 +27,11 @@ #' data$Petal.Length <- data$Petal.Length^2 #' #' model <- mgcv::gam(Sepal.Width ~ t2(Petal.Width, Petal.Length), data = data) -#' x <- estimate_slopes(model, by =c("Petal.Width", "Petal.Length"), length = 20) +#' x <- estimate_slopes(model, by = c("Petal.Width", "Petal.Length"), length = 20) #' plot(visualisation_recipe(x)) #' #' model <- mgcv::gam(Sepal.Width ~ t2(Petal.Width, Petal.Length, by = Species), data = data) -#' x <- estimate_slopes(model, by =c("Petal.Width", "Petal.Length", "Species"), length = 10) +#' x <- estimate_slopes(model, by = c("Petal.Width", "Petal.Length", "Species"), length = 10) #' plot(visualisation_recipe(x)) #' } #' } diff --git a/man/visualisation_recipe.estimate_predicted.Rd b/man/visualisation_recipe.estimate_predicted.Rd index 152784e8c..ed153808e 100644 --- a/man/visualisation_recipe.estimate_predicted.Rd +++ b/man/visualisation_recipe.estimate_predicted.Rd @@ -126,11 +126,11 @@ data$cyl <- as.factor(data$cyl) data$new_factor <- as.factor(rep(c("A", "B"), length.out = nrow(mtcars))) model <- lm(mpg ~ new_factor * cyl * wt, data = data) -x <- estimate_means(model, by =c("new_factor", "cyl")) +x <- estimate_means(model, by = c("new_factor", "cyl")) plot(visualisation_recipe(x)) # Modulations -------------- -x <- estimate_means(model, by =c("new_factor", "wt")) +x <- estimate_means(model, by = c("new_factor", "wt")) plot(visualisation_recipe(x)) # x <- estimate_means(model, by =c("new_factor", "cyl", "wt")) @@ -257,18 +257,18 @@ if (require("ggplot2") && require("rstanarm")) { # ============================================== if (require("ggplot2")) { model <- lm(Sepal.Width ~ Species * Petal.Length, data = iris) - x <- estimate_slopes(model, trend = "Petal.Length", by ="Species") + x <- estimate_slopes(model, trend = "Petal.Length", by = "Species") layers <- visualisation_recipe(x) layers plot(layers) model <- lm(Petal.Length ~ poly(Sepal.Width, 4), data = iris) - x <- estimate_slopes(model, by ="Sepal.Width", length = 20) + x <- estimate_slopes(model, by = "Sepal.Width", length = 20) plot(visualisation_recipe(x)) model <- lm(Petal.Length ~ Species * poly(Sepal.Width, 3), data = iris) - x <- estimate_slopes(model, by =c("Sepal.Width", "Species")) + x <- estimate_slopes(model, by = c("Sepal.Width", "Species")) plot(visualisation_recipe(x)) } \donttest{ @@ -278,11 +278,11 @@ if (require("mgcv")) { data$Petal.Length <- data$Petal.Length^2 model <- mgcv::gam(Sepal.Width ~ t2(Petal.Width, Petal.Length), data = data) - x <- estimate_slopes(model, by =c("Petal.Width", "Petal.Length"), length = 20) + x <- estimate_slopes(model, by = c("Petal.Width", "Petal.Length"), length = 20) plot(visualisation_recipe(x)) model <- mgcv::gam(Sepal.Width ~ t2(Petal.Width, Petal.Length, by = Species), data = data) - x <- estimate_slopes(model, by =c("Petal.Width", "Petal.Length", "Species"), length = 10) + x <- estimate_slopes(model, by = c("Petal.Width", "Petal.Length", "Species"), length = 10) plot(visualisation_recipe(x)) } } diff --git a/tests/testthat/test-estimate_predicted.R b/tests/testthat/test-estimate_predicted.R index 35089622c..1617520c2 100644 --- a/tests/testthat/test-estimate_predicted.R +++ b/tests/testthat/test-estimate_predicted.R @@ -169,6 +169,5 @@ test_that("estimate_response - VisMatrix", { vm <- visualisation_matrix(m, by = c("Petal.Length", "Petal.Width = seq(-3, 3)")) estim <- estimate_relation(vm) expect_identical(dim(estim), c(70L, 6L)) - expect_named(estim, c("Petal.Length", "Petal.Width", "Predicted", "SE", "CI_low", "CI_high") - ) + expect_named(estim, c("Petal.Length", "Petal.Width", "Predicted", "SE", "CI_low", "CI_high")) })