diff --git a/.github/workflows/R-check.yaml b/.github/workflows/R-check.yaml index 0e085829..e09bae2a 100644 --- a/.github/workflows/R-check.yaml +++ b/.github/workflows/R-check.yaml @@ -25,7 +25,7 @@ jobs: - {os: macOS-latest, r: 'release'} - {os: ubuntu-18.04, r: 'release'} - {os: windows-latest, r: 'oldrel'} - - {os: macOS-latest, r: 'oldrel'} + #- {os: macOS-latest, r: 'oldrel'} - {os: ubuntu-18.04, r: 'oldrel'} - {os: ubuntu-18.04, r: '3.6.0'} - {os: ubuntu-18.04, r: '3.5.0'} diff --git a/DESCRIPTION b/DESCRIPTION index 66572e4d..4c9b2994 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,11 +44,11 @@ URL: https://easystats.github.io/report/ BugReports: https://github.com/easystats/report/issues Imports: bayestestR (>= 0.11.5), - effectsize (>= 0.5.0.1), - insight (>= 0.14.5), - parameters (>= 0.15.0), + effectsize (>= 0.6.0), + insight (>= 0.15.0), + parameters (>= 0.16.0), performance (>= 0.8.0), - datawizard (>= 0.2.1), + datawizard (>= 0.2.2), stats, tools, utils @@ -61,7 +61,7 @@ Suggests: lavaan, lme4, logspline, - poorman, + dplyr, rmarkdown, rstanarm, spelling, @@ -79,7 +79,6 @@ Collate: 'format_citation.R' 'format_formula.R' 'format_model.R' - 'format_text.R' 'utils_combine_tables.R' 'report.lm.R' 'report.MixMod.R' @@ -119,7 +118,6 @@ Collate: 'report_sample.R' 'report_statistics.R' 'report_table.R' - 'utils_data.R' 'utils_error_message.R' 'utils_grouped_df.R' Roxygen: list(markdown = TRUE) diff --git a/NAMESPACE b/NAMESPACE index 4a57ce4d..cc66f643 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -267,17 +267,10 @@ export(cite_citation) export(cite_easystats) export(cite_packages) export(clean_citation) -export(data_addprefix) -export(data_addsuffix) -export(data_findcols) -export(data_remove) -export(data_rename) -export(data_reorder) export(format_algorithm) export(format_citation) export(format_formula) export(format_model) -export(format_text) export(is.report) export(report) export(report_date) @@ -297,9 +290,6 @@ export(report_story) export(report_system) export(report_table) export(report_text) -export(text_concatenate) -export(text_fullstop) -export(text_lastchar) -export(text_paste) -export(text_remove) -export(text_wrap) +import(datawizard) +import(effectsize) +import(insight) diff --git a/NEWS.md b/NEWS.md index 4ad356e9..d7ef7aea 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,30 @@ # report 0.3.6 + +BREAKING CHANGES + +* The following functions have now been removed from `report` and now live in [`datawizard`](https://easystats.github.io/datawizard/reference/index.html) package: + +Data wrangling helpers: + +- `data_addprefix()` +- `data_addsuffix()` +- `data_findcols()` +- `data_remove()` +- `data_rename()` +- `data_reorder()` + +Text formatting helpers: + +- `format_text()` +- `text_fullstop()` +- `text_lastchar()` +- `text_concatenate()` +- `text_paste()` +- `text_remove()` +- `text_wrap()` + +MAJOR CHANGES + * Separated sex and gender into different searches/columns * Sex is reported % female, % male, % other, % missing if any cases are missing * Gender is reported % Women, % Men, % Non-Binary, % missing if any cases are missing diff --git a/R/format_text.R b/R/format_text.R deleted file mode 100644 index 5180cc0d..00000000 --- a/R/format_text.R +++ /dev/null @@ -1,117 +0,0 @@ -#' Convenient text formatting functionalities -#' -#' Convenience functions to manipulate and format text. -#' -#' @param text,text2 A character string. -#' @param width Positive integer giving the target column width for wrapping -#' lines in the output. Can be "auto", in which case it will select 90\% of the -#' default width. -#' @inheritParams data_rename -#' @param sep Separator. -#' @param last Last separator. -#' @param n The number of characters to find. -#' @param ... Other arguments to be passed to or from other functions. -#' -#' @return A character string. -#' -#' @examples -#' library(report) -#' -#' # Add full stop if missing -#' text_fullstop(c("something", "something else.")) -#' -#' # Find last characters -#' text_lastchar(c("ABC", "DEF"), n = 2) -#' -#' # Smart concatenation -#' text_concatenate(c("First", "Second", "Last")) -#' -#' # Remove parts of string -#' text_remove(c("one!", "two", "three!"), "!") -#' -#' # Wrap text -#' long_text <- paste(rep("abc ", 100), collapse = "") -#' cat(text_wrap(long_text, width = 50)) -#' -#' # Paste with optional separator -#' text_paste(c("A", "", "B"), c("42", "42", "42")) -#' @export -format_text <- function(text, sep = ", ", last = " and ", width = NULL, ...) { - text_wrap(text_concatenate(text, sep = sep, last = last), width = width) -} - - -#' @rdname format_text -#' @export -text_fullstop <- function(text) { - text[!text_lastchar(text) %in% c(".", ":", ",", ";", "!", "?")] <- paste0(text[text_lastchar(text) != "."], ".") - text -} - - -#' @rdname format_text -#' @export -text_lastchar <- function(text, n = 1) { - sapply(text, function(xx) { - substr(xx, (nchar(xx) - n + 1), nchar(xx)) - }) -} - - -#' @rdname format_text -#' @export -text_concatenate <- function(text, sep = ", ", last = " and ") { - text <- text[text != ""] - if (length(text) == 1) { - text - } else { - s <- paste0(utils::head(text, -1), collapse = sep) - s <- paste0(c(s, utils::tail(text, 1)), collapse = last) - s - } -} - - -#' @rdname format_text -#' @export -text_paste <- function(text, text2 = NULL, sep = ", ", ...) { - if (!is.null(text2)) { - paste0(text, ifelse(text == "" | text2 == "", "", sep), text2) - } -} - - - -#' @rdname format_text -#' @export -text_remove <- function(text, pattern = "", ...) { - gsub(pattern, "", text, ...) -} - - -#' @rdname format_text -#' @export -text_wrap <- function(text, width = NULL, ...) { - if (is.null(width)) { - return(text) - } - - text <- strsplit(text, "\n", perl = TRUE) - text <- unlist(text) - - if (width == "auto") { - width <- 0.9 * getOption("width") - } - - wrapped <- "" - for (s in text) { - if (nchar(s) > width) { - leading_spaces <- nchar(s) - nchar(trimws(s)) - s <- strwrap(s, width = width) - s <- paste0(s, collapse = "\n") - s <- paste0(paste0(rep(" ", leading_spaces), collapse = ""), s) - } - wrapped <- paste0(wrapped, s, "\n") - } - wrapped -} diff --git a/R/report.R b/R/report.R index 58482ab0..b4b36d73 100644 --- a/R/report.R +++ b/R/report.R @@ -87,6 +87,10 @@ #' \item [report.default()] #' } #' +#' @import datawizard +#' @import effectsize +#' @import insight +#' #' @examples #' library(report) #' diff --git a/R/report.data.frame.R b/R/report.data.frame.R index ed9aafb5..f1c45eff 100644 --- a/R/report.data.frame.R +++ b/R/report.data.frame.R @@ -32,7 +32,7 @@ #' summary(as.data.frame(r)) #' #' # grouped analysis using `{dplyr}` package -#' if (require("poorman")) { +#' if (require("dplyr")) { #' r <- iris %>% #' group_by(Species) %>% #' report() diff --git a/R/report_participants.R b/R/report_participants.R index 25f9def9..8b3f0060 100644 --- a/R/report_participants.R +++ b/R/report_participants.R @@ -38,8 +38,10 @@ #' #' # Years of education (relative to high school graduation) #' data$Education <- c(0, 8, -3, -5, 3, 5) -#' report_participants(data, age = "Age", sex = "Sex", gender = "Gender", -#' education = "Education") +#' report_participants(data, +#' age = "Age", sex = "Sex", gender = "Gender", +#' education = "Education" +#' ) #' #' # Education as factor #' data$Education2 <- c( @@ -187,7 +189,7 @@ report_participants <- function(data, ) age <- "Age" sex <- "Sex" - gender <-"Gender" + gender <- "Gender" education <- "Education" } @@ -227,8 +229,7 @@ report_participants <- function(data, insight::format_value(100 - length(data[[sex]][tolower(data[[sex]]) %in% c("male", "m", "female", "f")]) / nrow(data) * 100, digits = digits), "% other" ) - } - else { + } else { paste0( "Sex: ", insight::format_value(length(data[[sex]][tolower(data[[sex]]) %in% c("female", "f")]) / nrow(data) * 100, digits = digits), @@ -239,7 +240,7 @@ report_participants <- function(data, "% other, ", insight::format_value(length(data[[sex]][tolower(data[[sex]]) %in% c(NA)]) / nrow(data) * 100), "% missing" - ) + ) } text_gender <- if (all(is.na(data[[gender]]))) { @@ -254,8 +255,7 @@ report_participants <- function(data, insight::format_value(100 - length(data[[gender]][tolower(data[[gender]]) %in% c("woman", "w", "man", "m")]) / nrow(data) * 100), "% non-binary" ) - } - else { + } else { paste0( "Gender: ", insight::format_value(length(data[[gender]][tolower(data[[gender]]) %in% c("woman", "w")]) / nrow(data) * 100, digits = digits), @@ -303,8 +303,8 @@ report_participants <- function(data, " participants (", ifelse(text_age == "", "", text_age), ifelse(text_sex == "", "", paste0(ifelse(text_age == "", "", "; "), text_sex)), - ifelse(text_gender == "", "", paste0(ifelse(text_age == "" & text_sex=="", "", "; "), text_gender)), - ifelse(text_education == "", "", paste0(ifelse(text_age == "" & text_sex == "" & text_gender== "","", "; "), text_education)), + ifelse(text_gender == "", "", paste0(ifelse(text_age == "" & text_sex == "", "", "; "), text_gender)), + ifelse(text_education == "", "", paste0(ifelse(text_age == "" & text_sex == "" & text_gender == "", "", "; "), text_education)), ")" ) } @@ -342,7 +342,7 @@ report_participants <- function(data, } #' @keywords internal -.find_gender_in_data <-function(data) { +.find_gender_in_data <- function(data) { if ("Gender" %in% colnames(data)) { "Gender" } else if ("gender" %in% colnames(data)) { diff --git a/R/utils_data.R b/R/utils_data.R deleted file mode 100644 index 8a2b46dc..00000000 --- a/R/utils_data.R +++ /dev/null @@ -1,116 +0,0 @@ -#' Convenient dataframe manipulation functionalities -#' -#' Safe and intuitive functions to manipulate dataframes. -#' -#' @param data Dataframe. -#' @param pattern,replacement,starts_with,ends_with Character strings. -#' @param cols Vector of column names. -#' @param safe Do not throw error if for instance the variable to be renamed/removed doesn't exist. -#' -#' @return A modified data frame. -#' -#' @examples -#' library(report) -#' -#' # Rename columns -#' data_rename(iris, "Sepal.Length", "length") -#' # data_rename(iris, "FakeCol", "length", safe=FALSE) # This fails -#' data_rename(iris, "FakeCol", "length") # This doesn't -#' data_rename(iris, c("Sepal.Length", "Sepal.Width"), c("length", "width")) -#' -#' # Find columns names by pattern -#' data_findcols(iris, starts_with = "Sepal") -#' data_findcols(iris, ends_with = "Width") -#' data_findcols(iris, pattern = "\\.") -#' -#' # Remove columns -#' data_remove(iris, "Sepal.Length") -#' -#' # Reorder columns -#' data_reorder(iris, c("Species", "Sepal.Length")) -#' data_reorder(iris, c("Species", "dupa")) -#' -#' # Add prefix / suffix -#' data_addprefix(iris, "NEW_") -#' data_addsuffix(iris, "_OLD") -#' @export -data_rename <- function(data, pattern, replacement, safe = TRUE) { - if (length(pattern) != length(replacement)) { - stop("The 'replacement' names must be of the same length than the variable names.") - } - - for (i in 1:length(pattern)) { - data <- .data_rename(data, pattern[i], replacement[i], safe) - } - data -} - -#' @keywords internal -.data_rename <- function(data, pattern, replacement, safe = TRUE) { - if (isFALSE(safe) & !pattern %in% names(data)) { - stop(paste0("Variable '", pattern, "' is not in your dataframe :/")) - } - names(data) <- replace(names(data), names(data) == pattern, replacement) - data -} - - - -#' @rdname data_rename -#' @export -data_findcols <- function(data, pattern = NULL, starts_with = NULL, ends_with = NULL) { - n <- names(data) - if (!is.null(pattern)) { - match <- c() - for (i in c(pattern)) { - match <- c(match, n[grepl(i, n)]) - } - } - if (!is.null(starts_with)) { - match <- n[grepl(paste0(starts_with, ".*"), n)] - } - if (!is.null(ends_with)) { - match <- n[grepl(paste0(".*", ends_with), n)] - } - match -} - - -#' @rdname data_rename -#' @export -data_remove <- function(data, pattern) { - new <- data[!names(data) %in% pattern] - attributes(new) <- utils::modifyList(attributes(data), attributes(new)) - class(new) <- class(data) - new -} - - -#' @rdname data_rename -#' @export -data_reorder <- function(data, cols, safe = TRUE) { - remaining_columns <- setdiff(names(data), cols) - if (isTRUE(safe)) cols <- cols[cols %in% names(data)] - data[, c(cols, remaining_columns)] -} - - - - - - - -#' @rdname data_rename -#' @export -data_addprefix <- function(data, pattern) { - names(data) <- paste0(pattern, names(data)) - data -} - - -#' @rdname data_rename -#' @export -data_addsuffix <- function(data, pattern) { - names(data) <- paste0(names(data), pattern) - data -} diff --git a/R/utils_grouped_df.R b/R/utils_grouped_df.R index dd754dfc..ceea33af 100644 --- a/R/utils_grouped_df.R +++ b/R/utils_grouped_df.R @@ -73,10 +73,15 @@ if (!isTRUE(drop) && any(is_factor)) { na_lvls <- do.call( expand.grid, - lapply(unique_groups, - function(x) if (is.factor(x)) { - levels(x)[!(levels(x) %in% x)] - } else NA + lapply( + unique_groups, + function(x) { + if (is.factor(x)) { + levels(x)[!(levels(x) %in% x)] + } else { + NA + } + } ) ) unique_groups <- rbind(unique_groups, na_lvls) diff --git a/README.Rmd b/README.Rmd index 0a626288..93050637 100644 --- a/README.Rmd +++ b/README.Rmd @@ -20,7 +20,7 @@ options( width = 80 ) -library(poorman) +library(dplyr) library(report) ``` diff --git a/README.md b/README.md index b41e88ce..e03c49b2 100644 --- a/README.md +++ b/README.md @@ -254,16 +254,16 @@ report(model) # 0.00, SD = 8.43) and normal (mean = 0.00, SD = 15.40) distributions. The # model's explanatory power is substantial (R2 = 0.81, 95% CI [0.69, 0.89], adj. # R2 = 0.79). The model's intercept, corresponding to qsec = 0 and wt = 0, is at - # 19.83 (95% CI [8.58, 30.19]). Within this model: + # 19.50 (95% CI [9.31, 30.34]). Within this model: # - # - The effect of qsec (Median = 0.92, 95% CI [0.40, 1.49]) has a 100.00% + # - The effect of qsec (Median = 0.94, 95% CI [0.42, 1.47]) has a 100.00% # probability of being positive (> 0), 98.80% of being significant (> 0.30), and - # 0.10% of being large (> 1.81). The estimation successfully converged (Rhat = - # 1.003) and the indices are reliable (ESS = 1470) - # - The effect of wt (Median = -5.03, 95% CI [-6.06, -4.18]) has a 100.00% + # 0.15% of being large (> 1.81). The estimation successfully converged (Rhat = + # 1.000) and the indices are reliable (ESS = 1991) + # - The effect of wt (Median = -5.03, 95% CI [-6.03, -4.10]) has a 100.00% # probability of being negative (< 0), 100.00% of being significant (< -0.30), # and 100.00% of being large (< -1.81). The estimation successfully converged - # (Rhat = 1.001) and the indices are reliable (ESS = 1562) + # (Rhat = 1.000) and the indices are reliable (ESS = 2341) # # Following the Sequential Effect eXistence and sIgnificance Testing (SEXIT) # framework, we report the median of the posterior distribution and its 95% CI @@ -312,7 +312,7 @@ paste( ) ``` - # [1] "Four participants (Mean age = 30.0, SD = 16.0, range: [21, 54]; 50.0% females) were recruited in the study by means of torture and coercion." + # [1] "Four participants (Mean age = 30.0, SD = 16.0, range: [21, 54]; Sex: 50.0% females, 50.0% males, 0.0% other) were recruited in the study by means of torture and coercion." ### Report sample @@ -336,18 +336,18 @@ report(sessionInfo()) ``` # Analyses were conducted using the R Statistical language (version 4.1.2; R Core - # Team, 2021) on Windows 10 x64 (build 19043), using the packages Rcpp (version - # 1.0.7; Dirk Eddelbuettel and Romain Francois, 2011), Matrix (version 1.3.4; + # Team, 2021) on Windows 10 x64 (build 19044), using the packages Rcpp (version + # 1.0.8; Dirk Eddelbuettel and Romain Francois, 2011), Matrix (version 1.3.4; # Douglas Bates and Martin Maechler, 2021), lme4 (version 1.1.27.1; Douglas Bates - # et al., 2015), rstanarm (version 2.21.1; Goodrich B et al., 2020), report - # (version 0.4.0.1; Makowski et al., 2020) and poorman (version 0.2.5; Nathan - # Eastwood, 2021). + # et al., 2015), rstanarm (version 2.21.1; Goodrich B et al., 2020), dplyr + # (version 1.0.7; Hadley Wickham et al., 2021) and report (version 0.4.0.1; + # Makowski et al., 2020). # # References # ---------- # - Dirk Eddelbuettel and Romain Francois (2011). Rcpp: Seamless R and C++ - # Integration. Journal of Statistical Software, 40(8), 1-18. URL - # https://www.jstatsoft.org/v40/i08/. + # Integration. Journal of Statistical Software, 40(8), 1-18, + # . # - Douglas Bates and Martin Maechler (2021). Matrix: Sparse and Dense Matrix # Classes and Methods. R package version 1.3-4. # https://CRAN.R-project.org/package=Matrix @@ -357,12 +357,13 @@ report(sessionInfo()) # - Goodrich B, Gabry J, Ali I & Brilleman S. (2020). rstanarm: Bayesian applied # regression modeling via Stan. R package version 2.21.1 # https://mc-stan.org/rstanarm. + # - Hadley Wickham, Romain François, Lionel Henry and Kirill Müller (2021). + # dplyr: A Grammar of Data Manipulation. R package version 1.0.7. + # https://CRAN.R-project.org/package=dplyr # - Makowski, D., Ben-Shachar, M.S., Patil, I. & Lüdecke, D. (2020). Automated # Results Reporting as a Practical Tool to Improve Reproducibility and # Methodological Best Practices Adoption. CRAN. Available from # https://github.com/easystats/report. doi: . - # - Nathan Eastwood (2021). poorman: A Poor Man's Dependency Free Recreation of - # 'dplyr'. R package version 0.2.5. https://CRAN.R-project.org/package=poorman # - R Core Team (2021). R: A language and environment for statistical computing. # R Foundation for Statistical Computing, Vienna, Austria. URL # https://www.R-project.org/. diff --git a/man/data_rename.Rd b/man/data_rename.Rd deleted file mode 100644 index 28258750..00000000 --- a/man/data_rename.Rd +++ /dev/null @@ -1,63 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils_data.R -\name{data_rename} -\alias{data_rename} -\alias{data_findcols} -\alias{data_remove} -\alias{data_reorder} -\alias{data_addprefix} -\alias{data_addsuffix} -\title{Convenient dataframe manipulation functionalities} -\usage{ -data_rename(data, pattern, replacement, safe = TRUE) - -data_findcols(data, pattern = NULL, starts_with = NULL, ends_with = NULL) - -data_remove(data, pattern) - -data_reorder(data, cols, safe = TRUE) - -data_addprefix(data, pattern) - -data_addsuffix(data, pattern) -} -\arguments{ -\item{data}{Dataframe.} - -\item{pattern, replacement, starts_with, ends_with}{Character strings.} - -\item{safe}{Do not throw error if for instance the variable to be renamed/removed doesn't exist.} - -\item{cols}{Vector of column names.} -} -\value{ -A modified data frame. -} -\description{ -Safe and intuitive functions to manipulate dataframes. -} -\examples{ -library(report) - -# Rename columns -data_rename(iris, "Sepal.Length", "length") -# data_rename(iris, "FakeCol", "length", safe=FALSE) # This fails -data_rename(iris, "FakeCol", "length") # This doesn't -data_rename(iris, c("Sepal.Length", "Sepal.Width"), c("length", "width")) - -# Find columns names by pattern -data_findcols(iris, starts_with = "Sepal") -data_findcols(iris, ends_with = "Width") -data_findcols(iris, pattern = "\\\\.") - -# Remove columns -data_remove(iris, "Sepal.Length") - -# Reorder columns -data_reorder(iris, c("Species", "Sepal.Length")) -data_reorder(iris, c("Species", "dupa")) - -# Add prefix / suffix -data_addprefix(iris, "NEW_") -data_addsuffix(iris, "_OLD") -} diff --git a/man/format_text.Rd b/man/format_text.Rd deleted file mode 100644 index 98fde1da..00000000 --- a/man/format_text.Rd +++ /dev/null @@ -1,71 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/format_text.R -\name{format_text} -\alias{format_text} -\alias{text_fullstop} -\alias{text_lastchar} -\alias{text_concatenate} -\alias{text_paste} -\alias{text_remove} -\alias{text_wrap} -\title{Convenient text formatting functionalities} -\usage{ -format_text(text, sep = ", ", last = " and ", width = NULL, ...) - -text_fullstop(text) - -text_lastchar(text, n = 1) - -text_concatenate(text, sep = ", ", last = " and ") - -text_paste(text, text2 = NULL, sep = ", ", ...) - -text_remove(text, pattern = "", ...) - -text_wrap(text, width = NULL, ...) -} -\arguments{ -\item{text, text2}{A character string.} - -\item{sep}{Separator.} - -\item{last}{Last separator.} - -\item{width}{Positive integer giving the target column width for wrapping -lines in the output. Can be "auto", in which case it will select 90\\% of the -default width.} - -\item{...}{Other arguments to be passed to or from other functions.} - -\item{n}{The number of characters to find.} - -\item{pattern}{Character strings.} -} -\value{ -A character string. -} -\description{ -Convenience functions to manipulate and format text. -} -\examples{ -library(report) - -# Add full stop if missing -text_fullstop(c("something", "something else.")) - -# Find last characters -text_lastchar(c("ABC", "DEF"), n = 2) - -# Smart concatenation -text_concatenate(c("First", "Second", "Last")) - -# Remove parts of string -text_remove(c("one!", "two", "three!"), "!") - -# Wrap text -long_text <- paste(rep("abc ", 100), collapse = "") -cat(text_wrap(long_text, width = 50)) - -# Paste with optional separator -text_paste(c("A", "", "B"), c("42", "42", "42")) -} diff --git a/man/report_participants.Rd b/man/report_participants.Rd index 7a00a0dd..85b8dfcd 100644 --- a/man/report_participants.Rd +++ b/man/report_participants.Rd @@ -8,6 +8,7 @@ report_participants( data, age = NULL, sex = NULL, + gender = NULL, education = NULL, participants = NULL, group = NULL, @@ -23,9 +24,13 @@ report_participants( \item{sex}{The name of the column containing the sex of the participant. The classes should be one of \code{c("Male", "M", "Female", "F")}. Note that -you can specify other characters here as well (e.g., \code{"Other"}), but -the function will report only percentage of females, regardless of whether -any category other than "Male" is present in the data.} +you can specify other characters here as well (e.g., \code{"Intersex"}), but +the function will group all individuals in those groups as \code{"Other"}.} + +\item{gender}{The name of the column containing the gender of the +The classes should be one of \code{c("Man", "M", "Woman", "F", "Non-Binary", "N")}. Note that you can specify other characters here as well +(e.g., \code{"Gender Fluid"}), but the function will group all individuals in +those groups as \code{"Non-Binary"}.} \item{education}{The name of the column containing education information.} @@ -54,36 +59,42 @@ the participants section. library(report) data <- data.frame( "Age" = c(22, 23, 54, 21, 8, 42), - "Sex" = c("F", "F", "M", "M", "M", "F") + "Sex" = c("Intersex", "F", "M", "M", "M", "F"), + "Gender" = c("N", "W", "W", "M", "M", "M") ) report_participants(data, age = "Age", sex = "Sex") # Years of education (relative to high school graduation) data$Education <- c(0, 8, -3, -5, 3, 5) -report_participants(data, age = "Age", sex = "Sex", education = "Education") +report_participants(data, + age = "Age", sex = "Sex", gender = "Gender", + education = "Education" +) # Education as factor data$Education2 <- c( "Bachelor", "PhD", "Highschool", "Highschool", "Bachelor", "Bachelor" ) -report_participants(data, age = "Age", sex = "Sex", education = "Education2") +report_participants(data, age = "Age", sex = "Sex", gender = "Gender", education = "Education2") # Repeated measures data data <- data.frame( "Age" = c(22, 22, 54, 54, 8, 8), - "Sex" = c("F", "F", "M", "M", "F", "F"), + "Sex" = c("I", "F", "M", "M", "F", "F"), + "Gender" = c("N", "W", "W", "M", "M", "M"), "Participant" = c("S1", "S1", "s2", "s2", "s3", "s3") ) -report_participants(data, age = "Age", sex = "Sex", participants = "Participant") +report_participants(data, age = "Age", sex = "Sex", gender = "Gender", participants = "Participant") # Grouped data data <- data.frame( "Age" = c(22, 22, 54, 54, 8, 8, 42, 42), - "Sex" = c("F", "F", "M", "M", "F", "F", "M", "M"), + "Sex" = c("I", "I", "M", "M", "F", "F", "F", "F"), + "Gender" = c("N", "N", "W", "M", "M", "M", "Non-Binary", "Non-Binary"), "Participant" = c("S1", "S1", "s2", "s2", "s3", "s3", "s4", "s4"), "Condition" = c("A", "A", "A", "A", "B", "B", "B", "B") ) @@ -91,6 +102,7 @@ data <- data.frame( report_participants(data, age = "Age", sex = "Sex", + gender = "Gender", participants = "Participant", group = "Condition" ) diff --git a/old/text_performance.lavaan.R b/old/text_performance.lavaan.R index 3074d0b6..452f6782 100644 --- a/old/text_performance.lavaan.R +++ b/old/text_performance.lavaan.R @@ -32,7 +32,7 @@ text_performance.lavaan <- function(model, performance, ...) { data.frame( Name = "GFI", Value = performance$GFI, - Interpretation = interpret_gfi(performance$GFI), + Interpretation = effectsize::interpret_gfi(performance$GFI), Threshold = 0.95 ) ) @@ -45,7 +45,7 @@ text_performance.lavaan <- function(model, performance, ...) { data.frame( Name = "AGFI", Value = performance$AGFI, - Interpretation = interpret_agfi(performance$AGFI), + Interpretation = effectsize::interpret_agfi(performance$AGFI), Threshold = 0.90 ) ) @@ -58,7 +58,7 @@ text_performance.lavaan <- function(model, performance, ...) { data.frame( Name = "NFI", Value = performance$NFI, - Interpretation = interpret_nfi(performance$NFI, rules = "byrne1994"), + Interpretation = effectsize::interpret_nfi(performance$NFI, rules = "byrne1994"), Threshold = 0.90 ) ) @@ -71,7 +71,7 @@ text_performance.lavaan <- function(model, performance, ...) { data.frame( Name = "NNFI", Value = performance$NNFI, - Interpretation = interpret_nnfi(performance$NNFI, rules = "byrne1994"), + Interpretation = effectsize::interpret_nnfi(performance$NNFI, rules = "byrne1994"), Threshold = 0.90 ) ) @@ -84,7 +84,7 @@ text_performance.lavaan <- function(model, performance, ...) { data.frame( Name = "CFI", Value = performance$CFI, - Interpretation = interpret_cfi(performance$CFI), + Interpretation = effectsize::interpret_cfi(performance$CFI), Threshold = 0.90 ) ) @@ -97,7 +97,7 @@ text_performance.lavaan <- function(model, performance, ...) { data.frame( Name = "RMSEA", Value = performance$RMSEA, - Interpretation = interpret_rmsea(performance$RMSEA), + Interpretation = effectsize::interpret_rmsea(performance$RMSEA), Threshold = 0.05 ) ) @@ -110,7 +110,7 @@ text_performance.lavaan <- function(model, performance, ...) { data.frame( Name = "SRMR", Value = performance$SRMR, - Interpretation = interpret_srmr(performance$SRMR), + Interpretation = effectsize::interpret_srmr(performance$SRMR), Threshold = 0.08 ) ) @@ -123,7 +123,7 @@ text_performance.lavaan <- function(model, performance, ...) { data.frame( Name = "RFI", Value = performance$RFI, - Interpretation = interpret_rfi(performance$RFI), + Interpretation = effectsize::interpret_rfi(performance$RFI), Threshold = 0.90 ) ) @@ -136,7 +136,7 @@ text_performance.lavaan <- function(model, performance, ...) { data.frame( Name = "IFI", Value = performance$IFI, - Interpretation = interpret_ifi(performance$IFI), + Interpretation = effectsize::interpret_ifi(performance$IFI), Threshold = 0.90 ) ) @@ -149,7 +149,7 @@ text_performance.lavaan <- function(model, performance, ...) { data.frame( Name = "PNFI", Value = performance$PNFI, - Interpretation = interpret_pnfi(performance$PNFI), + Interpretation = effectsize::interpret_pnfi(performance$PNFI), Threshold = 0.50 ) ) diff --git a/tests/testthat/_snaps/report.aov.md b/tests/testthat/_snaps/report.aov.md index e6477b80..8c7547b9 100644 --- a/tests/testthat/_snaps/report.aov.md +++ b/tests/testthat/_snaps/report.aov.md @@ -8,7 +8,7 @@ Output The ANOVA suggests that: - - The main effect of Species is statistically significant and large (F(2, 147) = 49.16, p < .001; Eta2 = 0.40, 90% CI [0.30, 0.48]) + - The main effect of Species is statistically significant and large (F(2, 147) = 49.16, p < .001; Eta2 = 0.40, 95% CI [0.30, 1.00]) Effect sizes were labelled following Field's (2013) recommendations. @@ -19,9 +19,9 @@ Output The ANOVA suggests that: - - The main effect of as.factor(am) is statistically significant and large (F(1, 26) = 45.39, p < .001; Eta2 (partial) = 0.64, 90% CI [0.43, 0.75]) - - The main effect of as.factor(cyl) is statistically significant and large (F(2, 26) = 11.53, p < .001; Eta2 (partial) = 0.47, 90% CI [0.21, 0.63]) - - The interaction between as.factor(am) and as.factor(cyl) is statistically not significant and very small (F(2, 26) = 0.11, p = 0.899; Eta2 (partial) = 8.13e-03, 90% CI [0.00, 0.05]) + - The main effect of as.factor(am) is statistically significant and large (F(1, 26) = 45.39, p < .001; Eta2 (partial) = 0.64, 95% CI [0.43, 1.00]) + - The main effect of as.factor(cyl) is statistically significant and large (F(2, 26) = 11.53, p < .001; Eta2 (partial) = 0.47, 95% CI [0.21, 1.00]) + - The interaction between as.factor(am) and as.factor(cyl) is statistically not significant and very small (F(2, 26) = 0.11, p = 0.899; Eta2 (partial) = 8.13e-03, 95% CI [0.00, 1.00]) Effect sizes were labelled following Field's (2013) recommendations. @@ -32,7 +32,8 @@ Output The repeated-measures ANOVA (formula: wt ~ cyl + Error(gear)) suggests that: - - The main effect of cyl is statistically significant and large (F(1, 29) = 27.94, p < .001; Eta2 (partial) = 0.49, 90% CI [0.27, 0.64]) + - The main effect of cyl is statistically significant and large (F(1, 29) = 27.94, p < .001; Eta2 (partial) = 1.00, 95% CI [, 1.00]) + - The main effect of cyl is statistically significant and large (F(1, 29) = 27.94, p < .001; Eta2 (partial) = 0.49, 95% CI [0.27, 1.00]) Effect sizes were labelled following Field's (2013) recommendations. diff --git a/tests/testthat/_snaps/report.htest-correlation.md b/tests/testthat/_snaps/report.htest-correlation.md deleted file mode 100644 index 9b9e197f..00000000 --- a/tests/testthat/_snaps/report.htest-correlation.md +++ /dev/null @@ -1,31 +0,0 @@ -# report.htest-correlation - - Code - report(cor.test(mtcars$wt, mtcars$mpg)) - Output - Effect sizes were labelled following Funder's (2019) recommendations. - - The Pearson's product-moment correlation between mtcars$wt and mtcars$mpg is negative, statistically significant, and very large (r = -0.87, 95% CI [-0.93, -0.74], t(30) = -9.56, p < .001) - ---- - - Code - report(cor.test(mtcars$wt, mtcars$mpg, method = "spearman")) - Warning - Cannot compute exact p-value with ties - Output - Effect sizes were labelled following Funder's (2019) recommendations. - - The Spearman's rank correlation rho between mtcars$wt and mtcars$mpg is negative, statistically significant, and very large (rho = -0.89, S = 10292.32, p < .001) - ---- - - Code - report(cor.test(mtcars$wt, mtcars$mpg, method = "kendall")) - Warning - Cannot compute exact p-value with ties - Output - Effect sizes were labelled following Funder's (2019) recommendations. - - The Kendall's rank correlation tau between mtcars$wt and mtcars$mpg is negative, statistically significant, and very large (tau = -0.73, z = -5.80, p < .001) - diff --git a/tests/testthat/_snaps/report.htest-t-test.md b/tests/testthat/_snaps/report.htest-t-test.md index c5ff8aae..cd19aa12 100644 --- a/tests/testthat/_snaps/report.htest-t-test.md +++ b/tests/testthat/_snaps/report.htest-t-test.md @@ -14,7 +14,7 @@ Output Effect sizes were labelled following Cohen's (1988) recommendations. - The One Sample t-test testing the difference between iris$Sepal.Width (mean = 3.06) and mu = -1 suggests that the effect is positive, statistically not significant, and large (difference = 4.06, 95% CI [-Inf, 3.12], t(149) = 114.01, p > .999; Cohen's d = 9.31, 95% CI [8.25, 10.40]) + The One Sample t-test testing the difference between iris$Sepal.Width (mean = 3.06) and mu = -1 suggests that the effect is positive, statistically not significant, and large (difference = 4.06, 95% CI [-Inf, 3.12], t(149) = 114.01, p > .999; Cohen's d = 9.31, 95% CI [-Inf, 10.22]) --- @@ -23,7 +23,7 @@ Output Effect sizes were labelled following Cohen's (1988) recommendations. - The One Sample t-test testing the difference between iris$Sepal.Width (mean = 3.06) and mu = 5 suggests that the effect is negative, statistically not significant, and large (difference = -1.94, 95% CI [3.00, Inf], t(149) = -54.59, p > .999; Cohen's d = -4.46, 95% CI [-5.80, -3.93]) + The One Sample t-test testing the difference between iris$Sepal.Width (mean = 3.06) and mu = 5 suggests that the effect is negative, statistically not significant, and large (difference = -1.94, 95% CI [3.00, Inf], t(149) = -54.59, p > .999; Cohen's d = -4.46, 95% CI [-4.91, Inf]) --- @@ -41,7 +41,7 @@ Output Effect sizes were labelled following Cohen's (1988) recommendations. - The Welch Two Sample t-test testing the difference of wt by am (mean in group 0 = 3.77, mean in group 1 = 2.41) suggests that the effect is positive, statistically not significant, and large (difference = 1.36, 95% CI [-Inf, 1.78], t(29.23) = 5.49, p > .999; Cohen's d = 2.03, 95% CI [1.13, 2.91]) + The Welch Two Sample t-test testing the difference of wt by am (mean in group 0 = 3.77, mean in group 1 = 2.41) suggests that the effect is positive, statistically not significant, and large (difference = 1.36, 95% CI [-Inf, 1.78], t(29.23) = 5.49, p > .999; Cohen's d = 2.03, 95% CI [-Inf, 2.77]) --- @@ -50,7 +50,7 @@ Output Effect sizes were labelled following Cohen's (1988) recommendations. - The Welch Two Sample t-test testing the difference of wt by am (mean in group 0 = 3.77, mean in group 1 = 2.41) suggests that the effect is positive, statistically significant, and large (difference = 1.36, 95% CI [0.94, Inf], t(29.23) = 5.49, p < .001; Cohen's d = 2.03, 95% CI [1.13, 2.91]) + The Welch Two Sample t-test testing the difference of wt by am (mean in group 0 = 3.77, mean in group 1 = 2.41) suggests that the effect is positive, statistically significant, and large (difference = 1.36, 95% CI [0.94, Inf], t(29.23) = 5.49, p < .001; Cohen's d = 2.03, 95% CI [1.27, Inf]) --- @@ -68,7 +68,7 @@ Output Effect sizes were labelled following Cohen's (1988) recommendations. - The Paired t-test testing the difference between x and y (mean of the differences = 0.43) suggests that the effect is positive, statistically not significant, and large (difference = 0.43, 95% CI [-Inf, 0.70], t(8) = 3.04, p = 0.992; Cohen's d = 1.07, 95% CI [0.19, 1.92]) + The Paired t-test testing the difference between x and y (mean of the differences = 0.43) suggests that the effect is positive, statistically not significant, and large (difference = 0.43, 95% CI [-Inf, 0.70], t(8) = 3.04, p = 0.992; Cohen's d = 1.07, 95% CI [-Inf, 1.77]) --- @@ -77,7 +77,7 @@ Output Effect sizes were labelled following Cohen's (1988) recommendations. - The Paired t-test testing the difference between x and y (mean of the differences = 0.43) suggests that the effect is positive, statistically significant, and large (difference = 0.43, 95% CI [0.17, Inf], t(8) = 3.04, p = 0.008; Cohen's d = 1.07, 95% CI [0.19, 1.92]) + The Paired t-test testing the difference between x and y (mean of the differences = 0.43) suggests that the effect is positive, statistically significant, and large (difference = 0.43, 95% CI [0.17, Inf], t(8) = 3.04, p = 0.008; Cohen's d = 1.07, 95% CI [0.32, Inf]) --- diff --git a/tests/testthat/_snaps/report.htest-t-test.new.md b/tests/testthat/_snaps/report.htest-t-test.new.md deleted file mode 100644 index 49694a48..00000000 --- a/tests/testthat/_snaps/report.htest-t-test.new.md +++ /dev/null @@ -1,90 +0,0 @@ -# report.htest-t-test - - Code - report(t.test(iris$Sepal.Width, mu = 1)) - Output - Effect sizes were labelled following Cohen's (1988) recommendations. - - The One Sample t-test testing the difference between iris$Sepal.Width (mean = 3.06) and mu = 1 suggests that the effect is positive, statistically significant, and large (difference = 2.06, 95% CI [2.99, 3.13], t(149) = 57.81, p < .001; Cohen's d = 4.72, 95% CI [4.17, 5.29]) - ---- - - Code - report(t.test(iris$Sepal.Width, mu = -1, alternative = "l")) - Output - Effect sizes were labelled following Cohen's (1988) recommendations. - - The One Sample t-test testing the difference between iris$Sepal.Width (mean = 3.06) and mu = -1 suggests that the effect is positive, statistically not significant, and large (difference = 4.06, 95% CI [-Inf, 3.12], t(149) = 114.01, p > .999; Cohen's d = 9.31, 95% CI [8.25, 10.40]) - ---- - - Code - report(t.test(iris$Sepal.Width, mu = 5, alternative = "g")) - Output - Effect sizes were labelled following Cohen's (1988) recommendations. - - The One Sample t-test testing the difference between iris$Sepal.Width (mean = 3.06) and mu = 5 suggests that the effect is negative, statistically not significant, and large (difference = -1.94, 95% CI [3.00, Inf], t(149) = -54.59, p > .999; Cohen's d = -4.46, 95% CI [-5.80, -3.93]) - ---- - - Code - report(t.test(formula = wt ~ am, data = mtcars)) - Output - Effect sizes were labelled following Cohen's (1988) recommendations. - - The Welch Two Sample t-test testing the difference of wt by am (mean in group 0 = 3.77, mean in group 1 = 2.41) suggests that the effect is negative, statistically significant, and large (difference = -1.36, 95% CI [0.85, 1.86], t(29.23) = 5.49, p < .001; Cohen's d = 2.03, 95% CI [1.13, 2.91]) - ---- - - Code - report(t.test(formula = wt ~ am, data = mtcars, alternative = "l")) - Output - Effect sizes were labelled following Cohen's (1988) recommendations. - - The Welch Two Sample t-test testing the difference of wt by am (mean in group 0 = 3.77, mean in group 1 = 2.41) suggests that the effect is negative, statistically not significant, and large (difference = -1.36, 95% CI [-Inf, 1.78], t(29.23) = 5.49, p > .999; Cohen's d = 2.03, 95% CI [1.13, 2.91]) - ---- - - Code - report(t.test(formula = wt ~ am, data = mtcars, alternative = "g")) - Output - Effect sizes were labelled following Cohen's (1988) recommendations. - - The Welch Two Sample t-test testing the difference of wt by am (mean in group 0 = 3.77, mean in group 1 = 2.41) suggests that the effect is negative, statistically significant, and large (difference = -1.36, 95% CI [0.94, Inf], t(29.23) = 5.49, p < .001; Cohen's d = 2.03, 95% CI [1.13, 2.91]) - ---- - - Code - report(t.test(x, y, paired = TRUE, data = mtcars)) - Output - Effect sizes were labelled following Cohen's (1988) recommendations. - - The Paired t-test testing the difference between x and y (mean of the differences = 0.43) suggests that the effect is positive, statistically significant, and large (difference = 0.43, 95% CI [0.10, 0.76], t(8) = 3.04, p = 0.016; Cohen's d = 1.07, 95% CI [0.19, 1.92]) - ---- - - Code - report(t.test(x, y, paired = TRUE, data = mtcars, alternative = "l")) - Output - Effect sizes were labelled following Cohen's (1988) recommendations. - - The Paired t-test testing the difference between x and y (mean of the differences = 0.43) suggests that the effect is positive, statistically not significant, and large (difference = 0.43, 95% CI [-Inf, 0.70], t(8) = 3.04, p = 0.992; Cohen's d = 1.07, 95% CI [0.19, 1.92]) - ---- - - Code - report(t.test(x, y, paired = TRUE, data = mtcars, alternative = "g")) - Output - Effect sizes were labelled following Cohen's (1988) recommendations. - - The Paired t-test testing the difference between x and y (mean of the differences = 0.43) suggests that the effect is positive, statistically significant, and large (difference = 0.43, 95% CI [0.17, Inf], t(8) = 3.04, p = 0.008; Cohen's d = 1.07, 95% CI [0.19, 1.92]) - ---- - - Code - report(t.test(Pair(extra.1, extra.2) ~ 1, data = sleep2)) - Output - Effect sizes were labelled following Cohen's (1988) recommendations. - - The Paired t-test testing the difference between Pair(extra.1, extra.2) (mean of the differences = -1.58) suggests that the effect is negative, statistically significant, and large (difference = -1.58, 95% CI [-2.46, -0.70], t(9) = -4.06, p = 0.003; Cohen's d = -1.35, 95% CI [-2.23, -0.44]) - diff --git a/tests/testthat/_snaps/report.ivreg.md b/tests/testthat/_snaps/report.ivreg.md index c0ffe20a..1dc24904 100644 --- a/tests/testthat/_snaps/report.ivreg.md +++ b/tests/testthat/_snaps/report.ivreg.md @@ -6,10 +6,10 @@ Formula contains log- or sqrt-terms. See help("standardize") for how such terms are standardized. Formula contains log- or sqrt-terms. See help("standardize") for how such terms are standardized. Output - We fitted a linear model to predict packs with rprice, rincome and salestax (formula: log(packs) ~ log(rprice) + log(rincome)). The model's explanatory power is substantial (R2 = 0.42, adj. R2 = 0.39). The model's intercept, corresponding to rprice = 0 and rincome = 0, is at 9.43 (95% CI [6.77, 12.09], t(45) = 6.94, p < .001). Within this model: + We fitted a linear model to predict packs with rprice, rincome and salestax (formula: log(packs) ~ log(rprice) + log(rincome)). The model's explanatory power is substantial (R2 = 0.42, adj. R2 = 0.39). The model's intercept, corresponding to rprice = 0 and rincome = 0, is at 9.43 (95% CI [6.69, 12.17], t(45) = 6.94, p < .001). Within this model: - - The effect of rprice [log] is statistically significant and negative (beta = -1.14, 95% CI [-1.85, -0.44], t(45) = -3.18, p = 0.003; Std. beta = -0.53, 95% CI [-0.85, -0.21]) - - The effect of rincome [log] is statistically non-significant and positive (beta = 0.21, 95% CI [-0.31, 0.74], t(45) = 0.80, p = 0.429; Std. beta = 0.12, 95% CI [-0.14, 0.38]) + - The effect of rprice [log] is statistically significant and negative (beta = -1.14, 95% CI [-1.87, -0.42], t(45) = -3.18, p = 0.003; Std. beta = -0.53, 95% CI [-0.86, -0.20]) + - The effect of rincome [log] is statistically non-significant and positive (beta = 0.21, 95% CI [-0.33, 0.76], t(45) = 0.80, p = 0.429; Std. beta = 0.12, 95% CI [-0.14, 0.39]) - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. + Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using the Wald approximation. diff --git a/tests/testthat/_snaps/report.lavaan.md b/tests/testthat/_snaps/report.lavaan.md index bc413fbc..c5d78314 100644 --- a/tests/testthat/_snaps/report.lavaan.md +++ b/tests/testthat/_snaps/report.lavaan.md @@ -5,10 +5,3 @@ Output [1] "Support for lavaan not fully implemented yet :(" -# model-lavaan detailed performance - - Code - report_performance(model) - Output - The model is not significantly different from a baseline model (Chi2(8) = 7.98, p = 0.435). The GFI (.97 > .95), AGFI (.91 > .90), NFI (.97 > .90), NNFI (.00 > .90), CFI (.00 > .90), RMSEA (.00 < .05), SRMR (.03 < .08), RFI (.95 > .90), IFI (.00 > .90) and PNFI (.52 > .50) suggest a satisfactory fit. - diff --git a/tests/testthat/_snaps/report.lm.md b/tests/testthat/_snaps/report.lm.md index 36481687..3698f71c 100644 --- a/tests/testthat/_snaps/report.lm.md +++ b/tests/testthat/_snaps/report.lm.md @@ -8,14 +8,14 @@ - The effect of Species [versicolor] is statistically significant and negative (beta = -0.66, 95% CI [-0.79, -0.52], t(147) = -9.69, p < .001; Std. beta = -1.51, 95% CI [-1.82, -1.20]) - The effect of Species [virginica] is statistically significant and negative (beta = -0.45, 95% CI [-0.59, -0.32], t(147) = -6.68, p < .001; Std. beta = -1.04, 95% CI [-1.35, -0.73]) - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. + Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using the Wald approximation. --- Code report(lm(wt ~ as.factor(am) * as.factor(cyl), data = mtcars)) Output - We fitted a linear model (estimated using OLS) to predict wt with am and cyl (formula: wt ~ as.factor(am) * as.factor(cyl)). The model explains a statistically significant and substantial proportion of variance (R2 = 0.73, F(5, 26) = 13.73, p < .001, adj. R2 = 0.67). The model's intercept, corresponding to am = 0 and cyl = 4, is at 2.94 (95% CI [2.27, 3.60], t(26) = 9.08, p < .001). Within this model: + We fitted a linear model (estimated using OLS) to predict wt with am and cyl (formula: wt ~ as.factor(am) * as.factor(cyl)). The model explains a statistically significant and substantial proportion of variance (R2 = 0.73, F(5, 26) = 13.73, p < .001, adj. R2 = 0.67). The model's intercept, corresponding to am = 0 and cyl = 0, is at 2.94 (95% CI [2.27, 3.60], t(26) = 9.08, p < .001). Within this model: - The effect of am [1] is statistically significant and negative (beta = -0.89, 95% CI [-1.67, -0.11], t(26) = -2.36, p = 0.026; Std. beta = -0.91, 95% CI [-1.71, -0.12]) - The effect of cyl [6] is statistically non-significant and positive (beta = 0.45, 95% CI [-0.43, 1.33], t(26) = 1.06, p = 0.298; Std. beta = 0.46, 95% CI [-0.43, 1.36]) @@ -23,7 +23,7 @@ - The interaction effect of as cyl6 on am [1] is statistically non-significant and positive (beta = 0.26, 95% CI [-0.92, 1.43], t(26) = 0.45, p = 0.654; Std. beta = 0.26, 95% CI [-0.94, 1.47]) - The interaction effect of as cyl8 on am [1] is statistically non-significant and positive (beta = 0.16, 95% CI [-1.02, 1.33], t(26) = 0.28, p = 0.783; Std. beta = 0.16, 95% CI [-1.04, 1.36]) - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. + Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using the Wald approximation. # report.lm - glm diff --git a/tests/testthat/_snaps/report.lm.new.md b/tests/testthat/_snaps/report.lm.new.md deleted file mode 100644 index ca687c98..00000000 --- a/tests/testthat/_snaps/report.lm.new.md +++ /dev/null @@ -1,49 +0,0 @@ -# report.lm - lm - - Code - report(lm(Sepal.Width ~ Species, data = iris)) - Output - We fitted a linear model (estimated using OLS) to predict Sepal.Width with Species (formula: Sepal.Width ~ Species). The model explains a statistically significant and substantial proportion of variance (R2 = 0.40, F(2, 147) = 49.16, p < .001, adj. R2 = 0.39). The model's intercept, corresponding to Species = setosa, is at 3.43 (95% CI [3.33, 3.52], t(147) = 71.36, p < .001). Within this model: - - - The effect of Species [versicolor] is statistically significant and negative (beta = -0.66, 95% CI [-0.79, -0.52], t(147) = -9.69, p < .001; Std. beta = -1.51, 95% CI [-1.82, -1.20]) - - The effect of Species [virginica] is statistically significant and negative (beta = -0.45, 95% CI [-0.59, -0.32], t(147) = -6.68, p < .001; Std. beta = -1.04, 95% CI [-1.35, -0.73]) - - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. - ---- - - Code - report(lm(wt ~ as.factor(am) * as.factor(cyl), data = mtcars)) - Output - We fitted a linear model (estimated using OLS) to predict wt with am and cyl (formula: wt ~ as.factor(am) * as.factor(cyl)). The model explains a statistically significant and substantial proportion of variance (R2 = 0.73, F(5, 26) = 13.73, p < .001, adj. R2 = 0.67). The model's intercept, corresponding to am = 0 and cyl = 4, is at 2.94 (95% CI [2.27, 3.60], t(26) = 9.08, p < .001). Within this model: - - - The effect of am [1] is statistically significant and negative (beta = -0.89, 95% CI [-1.67, -0.11], t(26) = -2.36, p = 0.026; Std. beta = -0.91, 95% CI [-1.71, -0.12]) - - The effect of cyl [6] is statistically non-significant and positive (beta = 0.45, 95% CI [-0.43, 1.33], t(26) = 1.06, p = 0.298; Std. beta = 0.46, 95% CI [-0.43, 1.36]) - - The effect of cyl [8] is statistically significant and positive (beta = 1.17, 95% CI [0.43, 1.91], t(26) = 3.23, p = 0.003; Std. beta = 1.19, 95% CI [0.44, 1.95]) - - The interaction effect of as.cyl6 on am [1] is statistically non-significant and positive (beta = 0.26, 95% CI [-0.92, 1.43], t(26) = 0.45, p = 0.654; Std. beta = 0.26, 95% CI [-0.94, 1.47]) - - The interaction effect of as.cyl8 on am [1] is statistically non-significant and positive (beta = 0.16, 95% CI [-1.02, 1.33], t(26) = 0.28, p = 0.783; Std. beta = 0.16, 95% CI [-1.04, 1.36]) - - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. - -# report.lm - glm - - Code - report(glm(vs ~ disp, data = mtcars, family = binomial(link = "probit"))) - Output - We fitted a probit model (estimated using ML) to predict vs with disp (formula: vs ~ disp). The model's explanatory power is substantial (Nagelkerke's R2 = 0.66). The model's intercept, corresponding to disp = 0, is at 2.51 (95% CI [1.13, 4.28], p = 0.001). Within this model: - - - The effect of disp is statistically significant and negative (beta = -0.01, 95% CI [-0.02, -6.45e-03], p < .001; Std. beta = -1.62, 95% CI [-2.79, -0.80]) - - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using - ---- - - Code - report(glm(vs ~ mpg, data = mtcars, family = "poisson")) - Output - We fitted a poisson model (estimated using ML) to predict vs with mpg (formula: vs ~ mpg). The model's explanatory power is substantial (Nagelkerke's R2 = 0.39). The model's intercept, corresponding to mpg = 0, is at -3.27 (95% CI [-5.46, -1.36], p = 0.002). Within this model: - - - The effect of mpg is statistically significant and positive (beta = 0.11, 95% CI [0.03, 0.19], p = 0.007; Std. beta = 0.66, 95% CI [0.18, 1.15]) - - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using - diff --git a/tests/testthat/_snaps/report.lmer.new.md b/tests/testthat/_snaps/report.lmer.new.md deleted file mode 100644 index 763bd629..00000000 --- a/tests/testthat/_snaps/report.lmer.new.md +++ /dev/null @@ -1,29 +0,0 @@ -# report-lmer - - Code - report(m1) - Output - We fitted a linear mixed model (estimated using REML and nloptwrap optimizer) to predict Reaction with Days (formula: Reaction ~ Days). The model included Days and Subject as random effects (formula: ~1 + Days | Subject). The model's total explanatory power is substantial (conditional R2 = 0.80) and the part related to the fixed effects alone (marginal R2) is of 0.28. The model's intercept, corresponding to Days = 0, is at 251.41 (95% CI [238.03, 264.78], t(174) = 36.84, p < .001). Within this model: - - - The effect of Days is statistically significant and positive (beta = 10.47, 95% CI [7.44, 13.50], t(174) = 6.77, p < .001; Std. beta = 0.54, 95% CI [0.38, 0.69]) - - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using the Wald approximation. - ---- - - Code - report(m2) - Message - boundary (singular) fit: see ?isSingular - Output - Random effect variances not available. Returned R2 does not account for random effects. - Message - boundary (singular) fit: see ?isSingular - Output - Random effect variances not available. Returned R2 does not account for random effects. - We fitted a linear mixed model (estimated using REML and nloptwrap optimizer) to predict Reaction with Days (formula: Reaction ~ Days). The model included mysubgrp, mygrp and Subject as random effects (formula: list(~1 | mysubgrp:mygrp, ~1 | mygrp, ~1 | Subject)). The model's explanatory power related to the fixed effects alone (marginal R2) is 0.49. The model's intercept, corresponding to Days = 0, is at 252.09 (95% CI [232.63, 271.55], t(174) = 25.39, p < .001). Within this model: - - - The effect of Days is statistically significant and positive (beta = 10.35, 95% CI [8.79, 11.92], t(174) = 12.95, p < .001; Std. beta = 0.53, 95% CI [0.45, 0.61]) - - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using the Wald approximation. - diff --git a/tests/testthat/_snaps/report.stanreg.md b/tests/testthat/_snaps/report.stanreg.md index 85122099..74c071d3 100644 --- a/tests/testthat/_snaps/report.stanreg.md +++ b/tests/testthat/_snaps/report.stanreg.md @@ -3,7 +3,7 @@ Code report(model) Output - We fitted a Bayesian linear model (estimated using MCMC sampling with 4 chains of 300 iterations and a warmup of 150) to predict mpg with qsec and wt (formula: mpg ~ qsec + wt). Priors over parameters were set as normal (mean = 0.00, SD = 8.43) and normal (mean = 0.00, SD = 15.40) distributions. The model's explanatory power is substantial (R2 = 0.81, 89% CI [0.73, 0.89], adj. R2 = 0.79). The model's intercept, corresponding to qsec = 0 and wt = 0, is at 19.71 (95% CI [9.25, 30.23]). Within this model: + We fitted a Bayesian linear model (estimated using MCMC sampling with 4 chains of 300 iterations and a warmup of 150) to predict mpg with qsec and wt (formula: mpg ~ qsec + wt). Priors over parameters were set as normal (mean = 0.00, SD = 8.43) and normal (mean = 0.00, SD = 15.40) distributions. The model's explanatory power is substantial (R2 = 0.81, 95% CI [0.70, 0.90], adj. R2 = 0.80). The model's intercept, corresponding to qsec = 0 and wt = 0, is at 19.71 (95% CI [9.25, 30.23]). Within this model: - The effect of qsec (Median = 0.92, 95% CI [0.40, 1.47]) has a 99.83% probability of being positive (> 0), 99.00% of being significant (> 0.30), and 0.33% of being large (> 1.81). The estimation successfully converged (Rhat = 0.999) but the indices are unreliable (ESS = 451) - The effect of wt (Median = -5.06, 95% CI [-6.02, -4.16]) has a 100.00% probability of being negative (< 0), 100.00% of being significant (< -0.30), and 100.00% of being large (< -1.81). However, the estimation might not have successfuly converged (Rhat = 1.013) and the indices are unreliable (ESS = 478) diff --git a/tests/testthat/_snaps/report.stanreg.new.md b/tests/testthat/_snaps/report.stanreg.new.md deleted file mode 100644 index 74c071d3..00000000 --- a/tests/testthat/_snaps/report.stanreg.new.md +++ /dev/null @@ -1,12 +0,0 @@ -# model-stanreg detailed - - Code - report(model) - Output - We fitted a Bayesian linear model (estimated using MCMC sampling with 4 chains of 300 iterations and a warmup of 150) to predict mpg with qsec and wt (formula: mpg ~ qsec + wt). Priors over parameters were set as normal (mean = 0.00, SD = 8.43) and normal (mean = 0.00, SD = 15.40) distributions. The model's explanatory power is substantial (R2 = 0.81, 95% CI [0.70, 0.90], adj. R2 = 0.80). The model's intercept, corresponding to qsec = 0 and wt = 0, is at 19.71 (95% CI [9.25, 30.23]). Within this model: - - - The effect of qsec (Median = 0.92, 95% CI [0.40, 1.47]) has a 99.83% probability of being positive (> 0), 99.00% of being significant (> 0.30), and 0.33% of being large (> 1.81). The estimation successfully converged (Rhat = 0.999) but the indices are unreliable (ESS = 451) - - The effect of wt (Median = -5.06, 95% CI [-6.02, -4.16]) has a 100.00% probability of being negative (< 0), 100.00% of being significant (< -0.30), and 100.00% of being large (< -1.81). However, the estimation might not have successfuly converged (Rhat = 1.013) and the indices are unreliable (ESS = 478) - - Following the Sequential Effect eXistence and sIgnificance Testing (SEXIT) framework, we report the median of the posterior distribution and its 95% CI (Highest Density Interval), along the probability of direction (pd), the probability of significance and the probability of being large. The thresholds beyond which the effect is considered as significant (i.e., non-negligible) and large are |0.30| and |1.81| (corresponding respectively to 0.05 and 0.30 of the outcome's SD). Convergence and stability of the Bayesian sampling has been assessed using R-hat, which should be below 1.01 (Vehtari et al., 2019), and Effective Sample Size (ESS), which should be greater than 1000 (Burkner, 2017). - diff --git a/tests/testthat/_snaps/report.survreg.md b/tests/testthat/_snaps/report.survreg.md index 691e696a..aa1267a4 100644 --- a/tests/testthat/_snaps/report.survreg.md +++ b/tests/testthat/_snaps/report.survreg.md @@ -15,5 +15,5 @@ - The effect of rx is statistically non-significant and positive (beta = 320.10, 95% CI [-194.11, 834.32], p = 0.222; Std. beta = 163.22, 95% CI [-98.98, 425.42]) - The effect of Log(scale) is statistically significant and positive (beta = 5.82, 95% CI [5.35, 6.29], p < .001; Std. beta = 5.82, 95% CI [5.35, 6.29]) - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. + Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using the Wald approximation. diff --git a/tests/testthat/_snaps/report.survreg.new.md b/tests/testthat/_snaps/report.survreg.new.md deleted file mode 100644 index 4d6a6573..00000000 --- a/tests/testthat/_snaps/report.survreg.new.md +++ /dev/null @@ -1,19 +0,0 @@ -# report-survreg - - Code - report(mod_survreg) - Output - Can't calculate log-loss. - Can't calculate proper scoring rules for models without integer response values. - `performance_pcp()` only works for models with binary response values. - Can't calculate log-loss. - Can't calculate proper scoring rules for models without integer response values. - `performance_pcp()` only works for models with binary response values. - We fitted a logistic model to predict Surv(futime, fustat) with ecog.ps and rx (formula: Surv(futime, fustat) ~ ecog.ps + rx). The model's explanatory power is weak (Nagelkerke's R2 = 0.07). The model's intercept, corresponding to ecog.ps = 0 and rx = 0, is at 667.43 (95% CI [-415.59, 1750.45], p = 0.227). Within this model: - - - The effect of ecog.ps is statistically non-significant and negative (beta = -210.59, 95% CI [-726.18, 305.01], p = 0.423; Std. beta = -107.06, 95% CI [-369.19, 155.07]) - - The effect of rx is statistically non-significant and positive (beta = 320.10, 95% CI [-194.11, 834.32], p = 0.222; Std. beta = 163.22, 95% CI [-98.98, 425.42]) - - The effect of Log(scale) is statistically significant and positive (beta = 5.82, 95% CI [5.35, 6.29], p < .001; Std. beta = 5.82, 95% CI [5.35, 6.29]) - - Standardized parameters were obtained by fitting the model on a standardized version of the dataset. - diff --git a/tests/testthat/test-report.aov.R b/tests/testthat/test-report.aov.R index d1138daa..3c101404 100644 --- a/tests/testthat/test-report.aov.R +++ b/tests/testthat/test-report.aov.R @@ -24,7 +24,7 @@ test_that("report.aov", { model <- aov(Sepal.Length ~ Species * Cat1 + Error(Cat2), data = data) r5 <- report(model) - expect_equal(c(ncol(as.report_table(r5, summary = TRUE)), nrow(as.report_table(r5, summary = TRUE))), c(8, 4)) + expect_equal(c(ncol(as.report_table(r5, summary = TRUE)), nrow(as.report_table(r5, summary = TRUE))), c(8, 5)) expect_equal(as.report_table(r5, summary = TRUE)$Mean_Square[1], 31.60607, tolerance = 0.01) # snapshot tests ----- diff --git a/tests/testthat/test-report.data.frame.R b/tests/testthat/test-report.data.frame.R index efbb5a69..2d40f11c 100644 --- a/tests/testthat/test-report.data.frame.R +++ b/tests/testthat/test-report.data.frame.R @@ -41,7 +41,7 @@ test_that("report.factor", { expect_equal(nrow(as.data.frame(r)), 4, tolerance = 0) }) -if (require("poorman")) { +if (require("dplyr")) { test_that("report.data.frame", { r <- report(iris) expect_equal(nrow(as.data.frame(r)), 7, tolerance = 0) diff --git a/vignettes/cite_packages.Rmd b/vignettes/cite_packages.Rmd index b3d23c79..0050ba24 100644 --- a/vignettes/cite_packages.Rmd +++ b/vignettes/cite_packages.Rmd @@ -27,7 +27,7 @@ options( width = 60 ) -if (!requireNamespace("poorman", quietly = TRUE)) { +if (!requireNamespace("dplyr", quietly = TRUE)) { knitr::opts_chunk$set(eval = FALSE) } ``` @@ -79,7 +79,7 @@ R, you can include (usually at the end) every used package's citation using the ```{r, results='asis'} library(report) -library(poorman) +library(dplyr) cite_packages() ``` diff --git a/vignettes/report.Rmd b/vignettes/report.Rmd index b82ca844..e17fade2 100644 --- a/vignettes/report.Rmd +++ b/vignettes/report.Rmd @@ -28,11 +28,11 @@ options( width = 60 ) -if (!requireNamespace("poorman", quietly = TRUE)) { +if (!requireNamespace("dplyr", quietly = TRUE)) { knitr::opts_chunk$set(eval = FALSE) } -library(poorman) +library(dplyr) ``` # Installation