Skip to content

Commit

Permalink
Switch from broom to generics
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-long committed Jul 4, 2019
1 parent 5968dd2 commit a6de891
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 61 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
36 changes: 8 additions & 28 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 0 additions & 12 deletions R/simple_margins.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...) {

Expand Down Expand Up @@ -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)))
Expand Down
12 changes: 0 additions & 12 deletions R/simple_slopes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...) {

Expand Down Expand Up @@ -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]])))
Expand Down
9 changes: 9 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions man/reexports.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/sim_margins_tidiers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/sim_slopes_tidiers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/test_sim_margins.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_sim_slopes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit a6de891

Please sign in to comment.