diff --git a/DESCRIPTION b/DESCRIPTION index 4151573..bd7fa49 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,11 +19,11 @@ LazyData: true Imports: ggplot2, crayon, cli, + generics, jtools (>= 2.0.0), rlang (>= 0.3.0), tibble Suggests: - broom, cowplot, ggstance, glue, diff --git a/NAMESPACE b/NAMESPACE index 63e0dad..61122ac 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,30 +1,6 @@ # Generated by roxygen2: do not edit by hand -if (getRversion() >= "3.6.0") { - S3method(broom::glance, sim_margins) -} else { - export(glance.sim_margins) -} - -if (getRversion() >= "3.6.0") { - S3method(broom::glance, sim_slopes) -} else { - export(glance.sim_slopes) -} - -if (getRversion() >= "3.6.0") { - S3method(broom::tidy, sim_margins) -} else { - export(tidy.sim_margins) -} - -if (getRversion() >= "3.6.0") { - S3method(broom::tidy, sim_slopes) -} else { - export(tidy.sim_slopes) -} - if (getRversion() >= "3.6.0") { S3method(huxtable::as_huxtable, sim_margins) } else { @@ -36,6 +12,8 @@ if (getRversion() >= "3.6.0") { } else { export(as_huxtable.sim_slopes) } +S3method(glance,sim_margins) +S3method(glance,sim_slopes) S3method(nobs,sim_margins) S3method(nobs,sim_slopes) S3method(plot,sim_margins) @@ -44,16 +22,16 @@ S3method(print,johnson_neyman) S3method(print,probe_interaction) S3method(print,sim_margins) S3method(print,sim_slopes) +S3method(tidy,sim_margins) +S3method(tidy,sim_slopes) export(cat_plot) -export(glance.sim_margins) -export(glance.sim_slopes) +export(glance) export(interact_plot) export(johnson_neyman) export(probe_interaction) export(sim_margins) export(sim_slopes) -export(tidy.sim_margins) -export(tidy.sim_slopes) +export(tidy) import(ggplot2) import(jtools) import(rlang) @@ -64,6 +42,8 @@ importFrom(crayon,inverse) importFrom(crayon,italic) importFrom(crayon,red) importFrom(crayon,underline) +importFrom(generics,glance) +importFrom(generics,tidy) importFrom(stats,aggregate) importFrom(stats,approx) importFrom(stats,as.formula) diff --git a/R/simple_margins.R b/R/simple_margins.R index 8a8eeb2..c8d6caf 100644 --- a/R/simple_margins.R +++ b/R/simple_margins.R @@ -351,12 +351,6 @@ print.sim_margins <- function(x, ...) { #' @param ... Ignored. #' @rdname sim_margins_tidiers #' @export -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(broom::tidy, sim_margins) -#' } else { -#' export(tidy.sim_margins) -#' } tidy.sim_margins <- function(x, conf.level = .95, ...) { @@ -447,12 +441,6 @@ tidy.sim_margins <- function(x, conf.level = .95, ...) { #' @rdname sim_margins_tidiers #' @export -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(broom::glance, sim_margins) -#' } else { -#' export(glance.sim_margins) -#' } glance.sim_margins <- function(x, ...) { tibble::as_tibble(data.frame(N = nobs(x))) diff --git a/R/simple_slopes.R b/R/simple_slopes.R index bdbd8de..257233a 100644 --- a/R/simple_slopes.R +++ b/R/simple_slopes.R @@ -790,12 +790,6 @@ print.sim_slopes <- function(x, ...) { #' @param ... Ignored. #' @rdname sim_slopes_tidiers #' @export -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(broom::tidy, sim_slopes) -#' } else { -#' export(tidy.sim_slopes) -#' } tidy.sim_slopes <- function(x, conf.level = .95, ...) { @@ -885,12 +879,6 @@ tidy.sim_slopes <- function(x, conf.level = .95, ...) { #' @rdname sim_slopes_tidiers #' @export -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(broom::glance, sim_slopes) -#' } else { -#' export(glance.sim_slopes) -#' } glance.sim_slopes <- function(x, ...) { data.frame(N = length(residuals(x$mods[[1]]))) diff --git a/R/utils.R b/R/utils.R index b98db7b..8bc994b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -198,3 +198,12 @@ cut2 <- function(x, cuts, m = 150, g, levels.mean = FALSE, # label(y) <- xlab y } + + +#'@export +#'@importFrom generics tidy +generics::tidy + +#'@export +#'@importFrom generics glance +generics::glance diff --git a/man/reexports.Rd b/man/reexports.Rd new file mode 100644 index 0000000..91519f0 --- /dev/null +++ b/man/reexports.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\docType{import} +\name{reexports} +\alias{reexports} +\alias{tidy} +\alias{glance} +\title{Objects exported from other packages} +\keyword{internal} +\description{ +These objects are imported from other packages. Follow the links +below to see their documentation. + +\describe{ + \item{generics}{\code{\link[generics]{tidy}}, \code{\link[generics]{glance}}} +}} + diff --git a/man/sim_margins_tidiers.Rd b/man/sim_margins_tidiers.Rd index d990bb9..e85a8a3 100644 --- a/man/sim_margins_tidiers.Rd +++ b/man/sim_margins_tidiers.Rd @@ -5,9 +5,9 @@ \alias{glance.sim_margins} \title{Tidiers for \code{\link[=sim_margins]{sim_margins()}} objects.} \usage{ -tidy.sim_margins(x, conf.level = 0.95, ...) +\method{tidy}{sim_margins}(x, conf.level = 0.95, ...) -glance.sim_margins(x, ...) +\method{glance}{sim_margins}(x, ...) } \arguments{ \item{x}{The \code{sim_margins} object} diff --git a/man/sim_slopes_tidiers.Rd b/man/sim_slopes_tidiers.Rd index 2ca6513..cfbea00 100644 --- a/man/sim_slopes_tidiers.Rd +++ b/man/sim_slopes_tidiers.Rd @@ -5,9 +5,9 @@ \alias{glance.sim_slopes} \title{Tidiers for \code{\link[=sim_slopes]{sim_slopes()}} objects.} \usage{ -tidy.sim_slopes(x, conf.level = 0.95, ...) +\method{tidy}{sim_slopes}(x, conf.level = 0.95, ...) -glance.sim_slopes(x, ...) +\method{glance}{sim_slopes}(x, ...) } \arguments{ \item{x}{The \code{sim_slopes} object} diff --git a/tests/testthat/test_sim_margins.R b/tests/testthat/test_sim_margins.R index 75eca0d..d975ac1 100644 --- a/tests/testthat/test_sim_margins.R +++ b/tests/testthat/test_sim_margins.R @@ -102,7 +102,7 @@ test_that("sim_margins works for lm w/ non-focal character", { context("sim_margins methods") -if (requireNamespace("huxtable") && requireNamespace("broom")) { +if (requireNamespace("huxtable") && requireNamespace("generics")) { test_that("as_huxtable.sim_margins works", { ss3 <- sim_margins(model = fit, pred = Murder, modx = Illiteracy, mod2 = HSGrad) @@ -124,7 +124,7 @@ if (requireNamespace("huxtable") && requireNamespace("broom")) { }) } -if (requireNamespace("ggstance") && requireNamespace("broom")) { +if (requireNamespace("ggstance") && requireNamespace("generics")) { test_that("plot.sim_margins works", { ss3 <- sim_margins(model = fit, pred = Murder, modx = Illiteracy, mod2 = HSGrad) diff --git a/tests/testthat/test_sim_slopes.R b/tests/testthat/test_sim_slopes.R index ea85c7e..a57e14a 100644 --- a/tests/testthat/test_sim_slopes.R +++ b/tests/testthat/test_sim_slopes.R @@ -69,7 +69,7 @@ test_that("sim_slopes works for lm w/ non-focal character", { context("sim_slopes methods") -if (requireNamespace("huxtable") && requireNamespace("broom")) { +if (requireNamespace("huxtable") && requireNamespace("generics")) { test_that("as_huxtable.sim_slopes works", { ss3 <- sim_slopes(model = fit, pred = Murder, modx = Illiteracy, mod2 = HSGrad) @@ -79,7 +79,7 @@ if (requireNamespace("huxtable") && requireNamespace("broom")) { }) } -if (requireNamespace("ggstance") && requireNamespace("broom")) { +if (requireNamespace("ggstance") && requireNamespace("generics")) { test_that("plot.sim_slopes works", { ss3 <- sim_slopes(model = fit, pred = Murder, modx = Illiteracy, mod2 = HSGrad)