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

Get builds to run on all supported R versions #499

Merged
merged 14 commits into from
May 11, 2024
9 changes: 6 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: datawizard
Title: Easy Data Wrangling and Statistical Transformations
Version: 0.10.0.2
Version: 0.10.0.3
Authors@R: c(
person("Indrajeet", "Patil", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0003-1995-6531", Twitter = "@patilindrajeets")),
Expand Down Expand Up @@ -42,18 +42,19 @@ Suggests:
brms,
curl,
data.table,
dplyr (>= 1.0),
dplyr (>= 1.1),
effectsize,
emmeans,
gamm4,
ggplot2,
ggplot2 (>= 3.5.0),
gt,
haven,
htmltools,
httr,
knitr,
lme4,
mediation,
modelbased,
parameters (>= 0.21.6),
poorman (>= 0.2.7),
psych,
Expand All @@ -67,6 +68,8 @@ Suggests:
tibble,
tidyr,
withr
Remotes:
easystats/modelbased
VignetteBuilder:
knitr
Encoding: UTF-8
Expand Down
3 changes: 2 additions & 1 deletion R/adjust.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#'
#' @return A data frame comparable to `data`, with adjusted variables.
#'
#' @examplesIf require("bayestestR", quietly = TRUE) && require("rstanarm", quietly = TRUE) && require("gamm4", quietly = TRUE)

Check warning on line 33 in R/adjust.R

View workflow job for this annotation

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

file=R/adjust.R,line=33,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 127 characters.

Check warning on line 33 in R/adjust.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/adjust.R,line=33,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 127 characters.
#' adjusted_all <- adjust(attitude)
#' head(adjusted_all)
#' adjusted_one <- adjust(attitude, effect = "complaints", select = "rating")
Expand All @@ -51,7 +51,8 @@
#' adjusted_icpt <- adjust(data, effect = "V1", select = "V2", keep_intercept = TRUE)
#'
#' # Visualize
#' plot(data$V1, data$V2,
#' plot(
#' data$V1, data$V2,
#' pch = 19, col = "blue",
#' ylim = c(min(adjusted$V2), max(data$V2)),
#' main = "Original (blue), adjusted (green), and adjusted - intercept kept (red) data"
Expand Down
8 changes: 4 additions & 4 deletions R/datawizard-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#' A lightweight package to assist in key steps involved in any data analysis
#' workflow:
#'
#' - wrangling the raw data to get it in the needed form,
#' - applying preprocessing steps and statistical transformations, and
#' - compute statistical summaries of data properties and distributions.
#' - wrangling the raw data to get it in the needed form,
#' - applying preprocessing steps and statistical transformations, and
#' - compute statistical summaries of data properties and distributions.
#'
#' It is also the data wrangling backend for packages in 'easystats' ecosystem.
#' References: Patil et al. (2022) \doi{10.21105/joss.04684}.
#' Reference: Patil et al. (2022) \doi{10.21105/joss.04684}.
#'
#' @docType package
#' @aliases datawizard datawizard-package
Expand Down
2 changes: 1 addition & 1 deletion R/row_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @param min_valid Optional, a numeric value of length 1. May either be
#' - a numeric value that indicates the amount of valid values per row to
#' calculate the row mean;
#' - or a value between 0 and 1, indicating a proportion of valid values per
#' - or a value between `0` and `1`, indicating a proportion of valid values per
#' row to calculate the row mean (see 'Details').
#' - `NULL` (default), in which all cases are considered.
#'
Expand Down Expand Up @@ -110,7 +110,7 @@
}

# proceed here if min_valid is not NULL
if (!is.null(min_valid)) {

Check warning on line 113 in R/row_means.R

View workflow job for this annotation

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

file=R/row_means.R,line=113,col=7,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
# is 'min_valid' indicating a proportion?
decimals <- min_valid %% 1
if (decimals != 0) {
Expand Down
6 changes: 3 additions & 3 deletions R/smoothness.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' Quantify the smoothness of a vector
#'
#' @param x Numeric vector (similar to a time series).
#' @param method Can be "diff" (the standard deviation of the standardized
#' differences) or "cor" (default, lag-one autocorrelation).
#' @param lag An integer indicating which lag to use. If less than 1, will be
#' @param method Can be `"diff"` (the standard deviation of the standardized
#' differences) or `"cor"` (default, lag-one autocorrelation).
#' @param lag An integer indicating which lag to use. If less than `1`, will be
#' interpreted as expressed in percentage of the length of the vector.
#' @inheritParams skewness
#'
Expand Down Expand Up @@ -39,13 +39,13 @@
}

if (method == "cor") {
smooth <- stats::cor(utils::head(x, length(x) - lag), utils::tail(x, length(x) - lag))

Check warning on line 42 in R/smoothness.R

View workflow job for this annotation

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

file=R/smoothness.R,line=42,col=5,[object_overwrite_linter] 'smooth' is an exported object from package 'stats'. Avoid re-using such symbols.
} else {
smooth <- stats::sd(diff(x, lag = lag)) / abs(mean(diff(x, lag = lag)))

Check warning on line 44 in R/smoothness.R

View workflow job for this annotation

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

file=R/smoothness.R,line=44,col=5,[object_overwrite_linter] 'smooth' is an exported object from package 'stats'. Avoid re-using such symbols.
}

if (!is.null(iterations)) {
if (!requireNamespace("boot", quietly = TRUE)) {

Check warning on line 48 in R/smoothness.R

View workflow job for this annotation

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

file=R/smoothness.R,line=48,col=9,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
insight::format_warning("Package 'boot' needed for bootstrapping SEs.")
} else {
results <- boot::boot(
Expand All @@ -56,7 +56,7 @@
lag = lag
)
out_se <- stats::sd(results$t, na.rm = TRUE)
smooth <- data.frame(Smoothness = smooth, SE = out_se)

Check warning on line 59 in R/smoothness.R

View workflow job for this annotation

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

file=R/smoothness.R,line=59,col=7,[object_overwrite_linter] 'smooth' is an exported object from package 'stats'. Avoid re-using such symbols.
}
}

Expand Down
2 changes: 1 addition & 1 deletion R/standardize.models.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@
weights = TRUE,
verbose = TRUE,
include_response = TRUE,
update_expr,

Check warning on line 99 in R/standardize.models.R

View workflow job for this annotation

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

file=R/standardize.models.R,line=99,col=33,[function_argument_linter] Arguments without defaults should come before arguments with defaults.
...) {
m_info <- .get_model_info(x, ...)
data <- insight::get_data(x, source = "mf", verbose = FALSE)

Check warning on line 102 in R/standardize.models.R

View workflow job for this annotation

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

file=R/standardize.models.R,line=102,col=3,[object_overwrite_linter] 'data' is an exported object from package 'utils'. Avoid re-using such symbols.

if (isTRUE(attr(data, "is_subset"))) {
insight::format_error("Cannot standardize a model fit with a 'subset = '.")
Expand Down Expand Up @@ -195,8 +195,8 @@




## ---- STANDARDIZE! ----

w <- insight::get_weights(x, na_rm = TRUE)

data_std <- standardize(data[do_standardize],
Expand Down Expand Up @@ -365,7 +365,7 @@


if (!is.null(covs)) {
covs <- mapply(.rescale_fixed_values, covs, names(covs),

Check warning on line 368 in R/standardize.models.R

View workflow job for this annotation

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

file=R/standardize.models.R,line=368,col=13,[undesirable_function_linter] Avoid undesirable function "mapply".
SIMPLIFY = FALSE,
MoreArgs = list(
y_data = y_data, m_data = m_data,
Expand All @@ -391,7 +391,7 @@
#
# control.value <- temp_vals[1]
# treat.value <- temp_vals[2]
# if (verbose) insight::format_alert("control and treatment values have been rescaled to their standardized scales.")

Check warning on line 394 in R/standardize.models.R

View workflow job for this annotation

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

file=R/standardize.models.R,line=394,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 121 characters.
# }

if (verbose && !all(c(control.value, treat.value) %in% c(0, 1))) {
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@


#' Fuzzy grep, matches pattern that are close, but not identical
#' Example:
#' @examples
#' colnames(iris)
#' p <- sprintf("(%s){~%i}", "Spela", 2)
#' grep(pattern = p, x = colnames(iris), ignore.case = FALSE)
Expand Down
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,20 +505,7 @@ To rescale a numeric variable to a new range:
``` r
change_scale(c(0, 1, 5, -5, -2))
#> [1] 50 60 100 0 30
#> attr(,"min_value")
#> [1] -5
#> attr(,"max_value")
#> [1] 5
#> attr(,"new_min")
#> [1] 0
#> attr(,"new_max")
#> [1] 100
#> attr(,"range_difference")
#> [1] 10
#> attr(,"to_range")
#> [1] 0 100
#> attr(,"class")
#> [1] "dw_transformer" "numeric"
#> (original range = -5 to 5)
```

### Rotate or transpose
Expand Down
4 changes: 2 additions & 2 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Bafumi
CMD
Carle
Catran
Crosstables
DOI
De
Dom
Expand Down Expand Up @@ -84,14 +85,13 @@ platykurtic
poorman
pth
px
quartile
quartiles
readr
readxl
recode
recoded
recodes
recoding
recodings
relevel
rempsyc
reproducibility
Expand Down
3 changes: 2 additions & 1 deletion man/adjust.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/datawizard-package.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/row_means.Rd

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

6 changes: 3 additions & 3 deletions man/smoothness.Rd

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

1 change: 0 additions & 1 deletion tests/testthat/test-data_tabulate.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ test_that("data_tabulate big numbers", {


test_that("data_tabulate print multiple, collapse", {
skip_if_not(packageVersion("insight") > "0.17.0", "insight must be >= 0.17.0")
data(efc, package = "datawizard")
expect_snapshot(data_tabulate(efc, c("c172code", "e16sex"), collapse = TRUE))
})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-standardize_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ test_that("transformations", {
ignore_attr = TRUE
)

skip_if_not_installed("insight", minimum_version = "0.10.0")
d <- data.frame(
time = as.factor(c(1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5)),
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2),
Expand Down Expand Up @@ -303,6 +302,7 @@ test_that("brms", {
skip_on_cran()
skip_on_os(c("windows", "mac"))
skip_if_not_installed("brms")
skip_if_not_installed("RcppEigen")

invisible(
capture.output({
Expand Down
Loading