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

R cmd check #588

Merged
merged 4 commits into from
Jul 1, 2024
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
5 changes: 4 additions & 1 deletion R/add_custom_effect_sizes.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

#' @keywords internal

add_custom_effect_sizes <- function(estimate, ...) {
UseMethod("add_custom_effect_sizes", estimate)
}

#' @keywords internal

add_custom_effect_sizes.character <- function(estimate, canonical_table, .x = NULL, ...) {

Expand All @@ -13,6 +14,7 @@ add_custom_effect_sizes.character <- function(estimate, canonical_table, .x = NU
add_effect_sizes(x = canonical_table, es = estimate, ...)
}

#' @keywords internal

add_custom_effect_sizes.data.frame <- function(estimate, canonical_table, intercept = FALSE, ...) {

Expand All @@ -32,6 +34,7 @@ add_custom_effect_sizes.data.frame <- function(estimate, canonical_table, interc
y
}

#' @keywords internal

add_custom_effect_sizes.function <- function(estimate, canonical_table, intercept = FALSE, .x = NULL, observed = NULL, ...) {

Expand Down
2 changes: 2 additions & 0 deletions R/apa_barplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ apa_barplot.default <- function(
, xlab = NULL
, ylab = NULL
, main = NULL
, set_par = TRUE
, ...
){
ellipsis <- defaults(
Expand All @@ -93,6 +94,7 @@ apa_barplot.default <- function(
, xlab = xlab
, ylab = ylab
, main = main
, set_par = set_par
, jit = .4 # add parameter 'space'
, plot = c("bars", "error_bars")
)
Expand Down
2 changes: 2 additions & 0 deletions R/apa_beeplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ apa_beeplot.default <- function(
, xlab = NULL
, ylab = NULL
, main = NULL
, set_par = TRUE
, ...
){
ellipsis <- defaults(
Expand All @@ -94,6 +95,7 @@ apa_beeplot.default <- function(
, xlab = xlab
, ylab = ylab
, main = main
, set_par = set_par
, plot = c("points", "error_bars", "swarms")
)
)
Expand Down
10 changes: 7 additions & 3 deletions R/apa_factorial_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#' @param ylab Character or expression. Label for *y* axis.
#' @param main Character or expression. For up to two factors, simply specify the main title. If you stratify the data by more than two factors,
#' either specify a single value that will be added to automatically generated main title, *or* specify an array of multiple titles, one for each plot area.
#' @param set_par Logical. Determines whether `par(mfrow = .)` should be set for multi-panel plots.
#' @return A named (nested) list of plot options including raw and derived data. *Note that the structure of the return value is about to change in a forthcoming release of papaja.*
#' @inheritDotParams graphics::plot.window
#' @details
Expand Down Expand Up @@ -114,6 +115,7 @@ apa_factorial_plot.default <- function(
, xlab = NULL
, ylab = NULL
, main = NULL
, set_par = TRUE
, ...
){
# Data validation:
Expand Down Expand Up @@ -149,6 +151,8 @@ apa_factorial_plot.default <- function(
if(!is.null(ylab)) if(!is.expression(ylab)) validate(ylab, check_class = "character")
if(!is.null(main)) if(!is.expression(main)) if(!is.matrix(main)) validate(main, check_class = "character")

set_par <- isTRUE(set_par)

# remove extraneous columns from dataset
data <- data[, c(id, factors, dv)]

Expand Down Expand Up @@ -392,7 +396,7 @@ apa_factorial_plot.default <- function(
output$args <- do.call("apa_factorial_plot_single", ellipsis)
}

if(length(factors) > 2L) {
if(length(factors) > 2L && set_par) {
oldpar <- par(no.readonly = TRUE)
on.exit(par(oldpar))
}
Expand All @@ -401,7 +405,7 @@ apa_factorial_plot.default <- function(


if(length(factors) == 3) {
par(mfrow = c(1, nlevels(data[[factors[3]]])))
if(set_par) par(mfrow = c(1, nlevels(data[[factors[3]]])))
tmp_main <- ellipsis$main

# by default, only plot legend in topright plot:
Expand Down Expand Up @@ -457,7 +461,7 @@ apa_factorial_plot.default <- function(

## Four factors
if(length(factors)==4){
par(mfrow=c(nlevels(data[[factors[3]]]),nlevels(data[[factors[4]]])))
if(set_par) par(mfrow=c(nlevels(data[[factors[3]]]),nlevels(data[[factors[4]]])))
tmp_main <- ellipsis$main

legend.plot <- array(FALSE, dim=c(nlevels(data[[factors[3]]]), nlevels(data[[factors[4]]])))
Expand Down
2 changes: 2 additions & 0 deletions R/apa_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ apa_lineplot.default <- function(
, xlab = NULL
, ylab = NULL
, main = NULL
, set_par = TRUE
, ...
){
ellipsis <- defaults(
Expand All @@ -97,6 +98,7 @@ apa_lineplot.default <- function(
, xlab = xlab
, ylab = ylab
, main = main
, set_par = set_par
, plot = c("points", "error_bars", "lines")
)
)
Expand Down
16 changes: 16 additions & 0 deletions R/apa_print_BFBayesFactor.R
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,16 @@ bf_sort_terms <- function(x) {

# }

#' @keywords internal

bf_add_estimates <- function(x, ...) UseMethod("bf_add_estimates", x@numerator[[1]])

#' @keywords internal

bf_add_estimates.default <- function(x, data_frame, ...) data_frame

#' @keywords internal

bf_add_estimates.BFoneSample <- function(
x
, data_frame
Expand Down Expand Up @@ -462,6 +467,7 @@ bf_add_estimates.BFoneSample <- function(
)
}

#' @keywords internal

bf_add_estimates.BFindepSample <- function(
x
Expand Down Expand Up @@ -495,6 +501,8 @@ bf_add_estimates.BFindepSample <- function(
)
}

#' @keywords internal

bf_add_estimates.BFcorrelation <- function(
x
, data_frame
Expand All @@ -510,6 +518,8 @@ bf_add_estimates.BFcorrelation <- function(
)
}

#' @keywords internal

bf_add_estimates.BFproportion <- function(
x
, data_frame
Expand All @@ -528,6 +538,7 @@ bf_add_estimates.BFproportion <- function(
)
}

#' @keywords internal

bf_sample_summarize <- function(
x
Expand Down Expand Up @@ -564,11 +575,16 @@ bf_sample_summarize <- function(
data_frame
}

#' @keywords internal

bf_add_names <- function(x, ...) UseMethod("bf_add_names", x@numerator[[1]])

#' @keywords internal

bf_add_names.default <- function(x, data_frame, ...) data_frame

#' @keywords internal

bf_add_names.BFlinearModel <- function(x, data_frame, ...) {
cbind(
model = names(x)$numerator
Expand Down
2 changes: 1 addition & 1 deletion R/apa_print_htest.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' large number of functions that produce these objects and their
#' idiosyncrasies, the returned strings should be compared to the original
#' object. If you experience inaccuracies you may report these
#' [here]{https://github.com/crsh/papaja/issues} (please include
#' [here](https://github.com/crsh/papaja/issues) (please include
#' a reproducible example in your report).
#'
#' `stat_name` and `est_name` are placed in the output string and are thus
Expand Down
7 changes: 7 additions & 0 deletions R/arrange_anova.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ arrange_anova <- function(x, ...) {
UseMethod("arrange_anova")
}

#' @keywords internal

arrange_anova.default <- function(x, ...) {
stop(paste0("Objects of class '", class(x), "' are currently not supported (no method defined).
Visit https://github.com/crsh/papaja/issues to request support for this class."))
Expand All @@ -43,6 +45,7 @@ arrange_anova.default <- function(x, ...) {

#' @rdname arrange_anova
#' @method arrange_anova anova
#' @keywords internal

arrange_anova.anova <- function(x, ...) {

Expand Down Expand Up @@ -83,6 +86,7 @@ arrange_anova.anova <- function(x, ...) {

#' @rdname arrange_anova
#' @method arrange_anova summary.aov
#' @keywords internal

arrange_anova.summary.aov <- function(x, ...) {

Expand Down Expand Up @@ -116,6 +120,8 @@ arrange_anova.summary.aov <- function(x, ...) {
variance_table
}

#' @keywords internal

arrange_anova.summary.aovlist <- function(x, ...) {
x <- lapply(x, arrange_anova.summary.aov)
variance_table <- do.call("rbind", x)
Expand All @@ -129,6 +135,7 @@ arrange_anova.summary.aovlist <- function(x, ...) {

#' @rdname arrange_anova
#' @method arrange_anova summary.Anova.mlm
#' @keywords internal

arrange_anova.summary.Anova.mlm <- function(x, correction = "GG", ...) {
validate(correction, check_class = "character", check_length = 1)
Expand Down
12 changes: 12 additions & 0 deletions R/tidy_es.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#' @keywords internal

tidy_es <- function(x) {
UseMethod("tidy_es", x)
}

#' @keywords internal

tidy_es.default <- function(x) {
tryCatch(
broom::tidy(x)
Expand All @@ -11,6 +15,8 @@ tidy_es.default <- function(x) {
)
}

#' @keywords internal

tidy_es.data.frame <- function(x) {
es_cols <- colnames(x)
if(
Expand All @@ -24,6 +30,8 @@ tidy_es.data.frame <- function(x) {
x
}

#' @keywords internal

tidy_es.effectsize_table <- function(x) {

x <- as.data.frame(x, stringsAsFactors = FALSE)
Expand All @@ -35,10 +43,14 @@ tidy_es.effectsize_table <- function(x) {
canonize(x)
}

#' @keywords internal

tidy_es.parameters_model <- function(x) {
tidy_es.effectsize_table(x)
}

#' @keywords internal

tidy_es.parameters_distribution <- function(x) {
tidy_es.effectsize_table(x)
}
5 changes: 2 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ validate <- function(
#' \describe{
#' \item{`estimate`}{A (named list of) character strings giving effect-size estimates.}
#' \item{`statistic`}{A (named list of) character strings giving test statistic, parameters, and *p* values.}
#' \item{`full_result`}{A (named list of) character strings comprised of `estimate` and `statistic`` for each factor.}
#' \item{`table`}{A data frame containing all results; can, for example, be passed to [apa_table()].
#' }
#' \item{`full_result`}{A (named list of) character strings comprised of `estimate` and `statistic` for each factor.}
#' \item{`table`}{A data frame containing all results; can, for example, be passed to [apa_table()].}
#' }
#' @keywords internal

Expand Down
3 changes: 3 additions & 0 deletions man/apa_barplot.Rd

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

3 changes: 3 additions & 0 deletions man/apa_beeplot.Rd

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

3 changes: 3 additions & 0 deletions man/apa_factorial_plot.Rd

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

3 changes: 3 additions & 0 deletions man/apa_lineplot.Rd

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

5 changes: 3 additions & 2 deletions man/apa_num.Rd

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

Loading
Loading