Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update snapshots #302

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Suggests:
splines,
testthat (>= 3.1.7),
tidygraph,
vdiffr (>= 1.0.5)
vdiffr (>= 1.0.6)
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
Expand Down
40 changes: 25 additions & 15 deletions R/plot.dw_data_tabulate.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,50 @@
#' @param error_bar Logical. Should error bars be displayed?
#' If `TRUE`, confidence intervals computed using the Wilson method are shown.
#' See Brown et al. (2001) for details.
#' @param ci Confidence Interval (CI) level. Default to `0.95` (95%).
#' @param fill_col Color to use for category columns (default: "#87CEFA").
#' @param color_error_bar Color to use for error bars (default: "#607B8B").
#' @param ci Confidence Interval (CI) level. Defaults to `0.95` (`95%`).
#' @param fill_col Color to use for category columns (default: `"#87CEFA"`).
#' @param color_error_bar Color to use for error bars (default: `"#607B8B"`).
#' @param ... Unused
#'
#' @references
#' Brown, L. D., Cai, T. T., & DasGupta, A. (2001).
#' Brown, L. D., Cai, T. T., & Dasgupta, A. (2001).
#' Interval estimation for a binomial proportion.
#' _Statistical Science, 16_(2), 101133. \doi{10.1214/ss/1009213286}
#' _Statistical Science_, _16_(2), 101-133. \doi{10.1214/ss/1009213286}
#'
#' @rdname plot.dw_data_tabulate
#' @export

plot.dw_data_tabulates <- function(x, label_values = TRUE,
show_na = c("if_any", "always", "never"),
na_label = "(Missing)",
error_bar = TRUE, ci = .95,
error_bar = TRUE,
ci = .95,

Check warning on line 31 in R/plot.dw_data_tabulate.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.dw_data_tabulate.R,line=31,col=41,[numeric_leading_zero_linter] Include the leading zero for fractional numeric constants.
fill_col = "#87CEFA",
color_error_bar = "#607B8B",
...) {
show_na <- match.arg(show_na, choices = c("if_any", "always", "never"))
if (length(x) == 1) {
if (length(x) == 1L) {
plot.dw_data_tabulate(
x[[1]],
label_values = label_values,
show_na = show_na, na_label = na_label,
error_bar = error_bar, ci = ci,
fill_col = fill_col, color_error_bar = color_error_bar
show_na = show_na,
na_label = na_label,
error_bar = error_bar,
ci = ci,
fill_col = fill_col,
color_error_bar = color_error_bar
)
} else {
lapply(x, plot.dw_data_tabulate,
lapply(
x,
plot.dw_data_tabulate,
label_values = label_values,
show_na = show_na, na_label = na_label,
error_bar = error_bar, ci = ci,
fill_col = fill_col, color_error_bar = color_error_bar
show_na = show_na,
na_label = na_label,
error_bar = error_bar,
ci = ci,
fill_col = fill_col,
color_error_bar = color_error_bar
)
}
}
Expand All @@ -57,7 +66,8 @@
plot.dw_data_tabulate <- function(x, label_values = TRUE,
show_na = c("if_any", "always", "never"),
na_label = "(Missing)",
error_bar = TRUE, ci = .95,
error_bar = TRUE,
ci = .95,

Check warning on line 70 in R/plot.dw_data_tabulate.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.dw_data_tabulate.R,line=70,col=40,[numeric_leading_zero_linter] Include the leading zero for fractional numeric constants.
fill_col = "#87CEFA",
color_error_bar = "#607B8B",
...) {
Expand All @@ -65,7 +75,7 @@
dat <- as.data.frame(x)

if (show_na == "if_any") {
if (any(is.na(dat$Value))) {

Check warning on line 78 in R/plot.dw_data_tabulate.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.dw_data_tabulate.R,line=78,col=9,[any_is_na_linter] anyNA(x) is better than any(is.na(x)).
show_na <- ifelse(dat[is.na(dat$Value), "N"] > 0, "always", "never")
} else {
show_na <- "never"
Expand Down Expand Up @@ -126,7 +136,7 @@
out
}

.wilson_ci <- function(prop, total_n, ci = .95) {

Check warning on line 139 in R/plot.dw_data_tabulate.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.dw_data_tabulate.R,line=139,col=44,[numeric_leading_zero_linter] Include the leading zero for fractional numeric constants.
z <- stats::qnorm((1 - ci) / 2, lower.tail = FALSE)
z2 <- z^2
p1 <- prop + 0.5 * z2 / total_n
Expand Down
2 changes: 1 addition & 1 deletion R/see-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' scales for 'ggplot2'. Color scales are based on
#' <https://materialui.co/colors>.
#'
#' References: Lüdecke et al. (2021) \doi{10.21105/joss.03393}.
#' References: Luedecke et al. (2021) \doi{10.21105/joss.03393}.
#'
#' @docType package
#' @aliases see see-package
Expand Down
4 changes: 2 additions & 2 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ Biserial
Blomqvist’s
Bluebrown
BossekJakob
CEFA
CMD
Cai
DOI
DasGupta
Dasgupta
Dom
GGMs
GeomViolinHalf
Geoms
HDI
Hoeffding’s
Luedecke
MPE
Mattan
Modelling
Expand Down
10 changes: 5 additions & 5 deletions man/plot.dw_data_tabulate.Rd

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

2 changes: 1 addition & 1 deletion man/see-package.Rd

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

6 changes: 3 additions & 3 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# graphics engine changed in R 4.1, and so snapshots generated on
# previous R version won't be compatible
if (require("testthat") && require("vdiffr") && getRversion() > "4.1.0") {
# graphics engine changed in these versions, and so snapshots generated on
# previous R version won't work
if (require("testthat") && require("vdiffr") && getRversion() > "4.1.0" && getRversion() < "4.4.0") {
library(testthat)
library(see)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading