Skip to content

Commit

Permalink
Merge branch 'main' into joss-paper-draft
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil authored Jul 4, 2023
2 parents befe297 + b0890cd commit bdc3ce5
Show file tree
Hide file tree
Showing 56 changed files with 1,397 additions and 319 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
^revdep$
^codecov\.yml$
^_pkgdown\.yml$
^pkgdown$
^data-raw$
^\.httr-oauth$
^CRAN-RELEASE$
Expand All @@ -22,4 +23,4 @@ tests\^spelling
^\.pre-commit-config\.yaml$
^WIP/.
\.code-workspace$
^CRAN-SUBMISSION$
^CRAN-SUBMISSION$
7 changes: 0 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/check-random-test-order.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Run tests in random order
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: check-random-test-order

jobs:
check-random-test-order:
uses: easystats/workflows/.github/workflows/check-random-test-order.yaml@main
1 change: 0 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
linters: linters_with_defaults(
absolute_path_linter = NULL,
commented_code_linter = NULL,
cyclocomp_linter = cyclocomp_linter(25),
extraction_operator_linter = NULL,
implicit_integer_linter = NULL,
Expand Down
24 changes: 17 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: report
Title: Automated Reporting of Results and Statistical Models
Version: 0.5.6
Version: 0.5.7.10
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
Expand Down Expand Up @@ -37,7 +37,12 @@ Authors@R:
family = "Siegel",
role = "ctb",
email = "[email protected]",
comment = c(ORCID = "0000-0002-6021-804X")))
comment = c(ORCID = "0000-0002-6021-804X")),
person(given = "Camden",
family = "Bock",
role = "ctb",
email = "[email protected]",
comment = c(ORCID = "0000-0002-3907-7748")))
Maintainer: Rémi Thériault <[email protected]>
Description: The aim of the 'report' package is to bridge the gap between
R’s output and the formatted results contained in your manuscript.
Expand All @@ -52,10 +57,10 @@ Depends:
Imports:
bayestestR (>= 0.13.0),
effectsize (> 0.8.2),
insight (>= 0.18.8),
parameters (>= 0.20.0),
performance (>= 0.9.2),
datawizard (>= 0.6.5),
insight (>= 0.19.1),
parameters (>= 0.20.2),
performance (>= 0.10.2),
datawizard (>= 0.7.0),
stats,
tools,
utils
Expand All @@ -69,12 +74,14 @@ Suggests:
rmarkdown,
rstanarm,
survival,
modelbased,
emmeans,
testthat
VignetteBuilder:
knitr
Encoding: UTF-8
Language: en-US
RoxygenNote: 7.2.3.9000
RoxygenNote: 7.2.3
Config/testthat/edition: 3
Config/Needs/website:
rstudio/bslib,
Expand All @@ -86,6 +93,7 @@ Collate:
'format_citation.R'
'format_formula.R'
'format_model.R'
'reexports.R'
'report-package.R'
'utils_combine_tables.R'
'report.lm.R'
Expand All @@ -102,6 +110,7 @@ Collate:
'report.compare_performance.R'
'report.data.frame.R'
'report.default.R'
'report.estimate_contrasts.R'
'report.factor.R'
'report.glm.R'
'report.glmmTMB.R'
Expand Down Expand Up @@ -134,3 +143,4 @@ Collate:
'utils_grouped_df.R'
'zzz.R'
Roxygen: list(markdown = TRUE)
Remotes: easystats/insight
14 changes: 14 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ S3method(print,report_sample)
S3method(print,report_statistics)
S3method(print,report_table)
S3method(print,report_text)
S3method(print_html,report_sample)
S3method(print_md,report_sample)
S3method(report,Date)
S3method(report,MixMod)
S3method(report,anova)
S3method(report,aov)
Expand All @@ -36,6 +39,7 @@ S3method(report,character)
S3method(report,compare_performance)
S3method(report,data.frame)
S3method(report,default)
S3method(report,estimate_contrasts)
S3method(report,factor)
S3method(report,glm)
S3method(report,glmmTMB)
Expand Down Expand Up @@ -113,6 +117,7 @@ S3method(report_model,merMod)
S3method(report_model,stanreg)
S3method(report_model,survreg)
S3method(report_model,zeroinfl)
S3method(report_parameters,Date)
S3method(report_parameters,MixMod)
S3method(report_parameters,anova)
S3method(report_parameters,aov)
Expand Down Expand Up @@ -161,6 +166,7 @@ S3method(report_random,glmmTMB)
S3method(report_random,lme)
S3method(report_random,merMod)
S3method(report_random,stanreg)
S3method(report_statistics,Date)
S3method(report_statistics,MixMod)
S3method(report_statistics,anova)
S3method(report_statistics,aov)
Expand All @@ -184,6 +190,7 @@ S3method(report_statistics,stanreg)
S3method(report_statistics,survreg)
S3method(report_statistics,test_performance)
S3method(report_statistics,zeroinfl)
S3method(report_table,Date)
S3method(report_table,MixMod)
S3method(report_table,anova)
S3method(report_table,aov)
Expand All @@ -195,6 +202,7 @@ S3method(report_table,character)
S3method(report_table,compare_performance)
S3method(report_table,data.frame)
S3method(report_table,default)
S3method(report_table,estimate_contrasts)
S3method(report_table,factor)
S3method(report_table,glm)
S3method(report_table,glmmTMB)
Expand All @@ -212,6 +220,7 @@ S3method(report_table,stanreg)
S3method(report_table,survreg)
S3method(report_table,test_performance)
S3method(report_table,zeroinfl)
S3method(report_text,Date)
S3method(report_text,MixMod)
S3method(report_text,anova)
S3method(report_text,aov)
Expand All @@ -223,6 +232,7 @@ S3method(report_text,character)
S3method(report_text,compare_performance)
S3method(report_text,data.frame)
S3method(report_text,default)
S3method(report_text,estimate_contrasts)
S3method(report_text,factor)
S3method(report_text,glm)
S3method(report_text,glmmTMB)
Expand Down Expand Up @@ -273,6 +283,8 @@ export(format_citation)
export(format_formula)
export(format_model)
export(is.report)
export(print_html)
export(print_md)
export(report)
export(report_date)
export(report_effectsize)
Expand All @@ -292,3 +304,5 @@ export(report_system)
export(report_table)
export(report_text)
importFrom(insight,display)
importFrom(insight,print_html)
importFrom(insight,print_md)
35 changes: 35 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# report 0.5.8

Minor changes

* `report` now supports variables of class `Date`, treating them like factors.

* `report` now supports objects of class `estimate_contrasts`, from easystats'
`modelbased::estimate_contrasts`, outputting either the results in text form,
or as a table.

* `report_sample`
* now reports the weighted number of observations when data
is both grouped an weighted.
* gains `ci`, `ci_method` and `ci_adjust` arguments, to compute
confidence intervals for proportions of factor levels. Currently, two different
methods (*Wald* and *Wilson*) are available.
* now works on grouped data frame, using the defined groups as
values for the `group_by` argument.
* can now summarize data based on more than one grouping variable
(i.e. `group_by` is allowed to be longer than 1).

* The `print` method for `report_sample` gains a `layout` argument, to print
tables either in `"horizontal"` or `"vertical"` layout.

Bug fixes

* Fixed issue in `report_participants`, which did not print the `"gender"`
category for grouped output when that argument was written in lower-case.

* Fixed printing issue for intercept-only models.

# report 0.5.7

Hotfix for CRAN reverse dependency compatibility.

# report 0.5.6

Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion R/format_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ format_model <- function(x) {
format_model.default <- function(x) {
info <- insight::model_info(x)

if (insight::is_nullmodel(x)) {
if (suppressWarnings(insight::is_nullmodel(x))) {
type <- "constant (intercept-only) "
} else {
type <- ""
Expand Down
13 changes: 13 additions & 0 deletions R/reexports.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ----------------------- insight -------------------------------------

#' @importFrom insight print_html
#' @export
insight::print_html

#' @importFrom insight print_md
#' @export
insight::print_md

#' @importFrom insight display
#' @export
insight::display
3 changes: 2 additions & 1 deletion R/report.aov.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ report_table.aov <- function(x, ...) {

table <- datawizard::data_remove(
table_full,
datawizard::data_find(table_full, select = "(_CI_low|_CI_high)$", regex = TRUE)
select = "(_CI_low|_CI_high)$",
regex = TRUE
)

as.report_table(
Expand Down
12 changes: 7 additions & 5 deletions R/report.brmsfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @inheritParams report.lm
#' @inherit report return seealso
#'
#' @examplesIf requireNamespace("brms", quietly = TRUE) && packageVersion("rstan") >= "2.26.0"
#' @examplesIf require("brms", quietly = TRUE)
#' \dontrun{
#' # Bayesian models
#' library(brms)
Expand Down Expand Up @@ -62,9 +62,11 @@ report_priors.brmsfit <- function(x, ...) {
params <- params[params$Parameter != "(Intercept)", ]

# Return empty if no priors info
if (!"Prior_Distribution" %in% names(params) ||
nrow(params) == 0 ||
all(is.na(params$Prior_Scale))) {
has_no_prior_information <- (!"Prior_Distribution" %in% names(params)) ||
nrow(params) == 0L ||
all(is.na(params$Prior_Scale))

if (has_no_prior_information) {
return("")
}

Expand All @@ -85,7 +87,7 @@ report_priors.brmsfit <- function(x, ...) {

values <- paste0(params$Prior_Distribution, " (", values, ")")

if (length(unique(values)) == 1 && nrow(params) > 1) {
if (length(unique(values)) == 1L && nrow(params) > 1L) {
text <- paste0("all set as ", values[1])
} else {
text <- paste0("set as ", values)
Expand Down
15 changes: 11 additions & 4 deletions R/report.data.frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,19 @@ report_table.grouped_df <- function(x,
)

current_table_full$Group <- group
# table_full <- rbind(table_full, current_table_full)
table_full <- merge(table_full, current_table_full, all = TRUE, sort = FALSE)
if (!length(table_full) == 0) {
table_full <- merge(table_full, current_table_full, all = TRUE, sort = FALSE)
} else {
table_full <- current_table_full
}

current_table <- summary(current_table_full)
current_table$Group <- group
# table <- rbind(table, current_table)
table <- merge(table, current_table, all = TRUE, sort = FALSE)
if (!length(table) == 0) {
table <- merge(table, current_table, all = TRUE, sort = FALSE)
} else {
table <- current_table
}
}

table <- datawizard::data_reorder(table, "Group")
Expand Down
52 changes: 52 additions & 0 deletions R/report.estimate_contrasts.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#' Reporting `estimate_contrasts` objects
#'
#' Create reports for `estimate_contrasts` objects.
#'
#' @param x Object of class `estimate_contrasts`.
#' @param table Provide the output of `report_table()` to avoid its
#' re-computation.
#' @inheritParams report
#'
#' @inherit report return seealso
#'
#' @examplesIf requireNamespace("modelbased", quietly = TRUE) && requireNamespace("emmeans", quietly = TRUE)
#' library(modelbased)
#' model <- lm(Sepal.Width ~ Species, data = iris)
#' contr <- estimate_contrasts(model)
#' report(contr)
#' @return An object of class [report()].
#' @export
report.estimate_contrasts <- function(x, ...) {
table <- report_table(x, ...)
text <- report_text(x, table = table, ...)

as.report(text, table = table, ...)
}

# report_table ------------------------------------------------------------

#' @rdname report.estimate_contrasts
#' @export
report_table.estimate_contrasts <- function(x, ...) {
as.report_table(x)
}

# report_text ------------------------------------------------------------

#' @rdname report.estimate_contrasts
#' @export
report_text.estimate_contrasts <- function(x, table = NULL, ...) {
f_table <- insight::format_table(table)

text <- paste0("The difference between ", x$Level1, " and ", x$Level2, " is ",
ifelse(x$Difference < 0, " negative", "positive"), " and statistically ",
ifelse(x$p < 0.05, "significant", "non-significant"),
" (difference = ", f_table$Difference, ", 95% CI ", f_table$`95% CI`, ", ",
names(f_table)[6], " = ", f_table[[6]], ", ", insight::format_p(table$p), ")",
collapse = ". "
)

text <- paste("The marginal contrasts analysis suggests the following.", paste0(text, collapse = ""))

as.report_text(text)
}
Loading

0 comments on commit bdc3ce5

Please sign in to comment.