diff --git a/R/convert_na_to.R b/R/convert_na_to.R
index 330c1ae45..e81bd8446 100644
--- a/R/convert_na_to.R
+++ b/R/convert_na_to.R
@@ -123,7 +123,8 @@ convert_na_to.character <- function(x, replacement = NULL, verbose = TRUE, ...)
if (is_empty_object(replacement) || !is.character(replacement) && !is.numeric(replacement)) {
if (isTRUE(verbose)) {
warning(insight::format_message(
- "`replacement` needs to be a character or numeric vector."), call. = FALSE)
+ "`replacement` needs to be a character or numeric vector."
+ ), call. = FALSE)
}
} else if (length(replacement) > 1) {
if (isTRUE(verbose)) {
diff --git a/R/data_reshape.R b/R/data_reshape.R
index d71dfc95d..df6bce0f9 100644
--- a/R/data_reshape.R
+++ b/R/data_reshape.R
@@ -58,16 +58,15 @@
#' rows_to = "Participant"
#' )
#'
-#' if(require("tidyr")) {
-#' reshape_longer(
-#' tidyr::who,
-#' select = new_sp_m014:newrel_f65,
-#' names_to = c("diagnosis", "gender", "age"),
-#' names_pattern = "new_?(.*)_(.)(.*)",
-#' values_to = "count"
-#' )
-#' }
-#'
+#' if (require("tidyr")) {
+#' reshape_longer(
+#' tidyr::who,
+#' select = new_sp_m014:newrel_f65,
+#' names_to = c("diagnosis", "gender", "age"),
+#' names_pattern = "new_?(.*)_(.)(.*)",
+#' values_to = "count"
+#' )
+#' }
#' }
#' }
#'
diff --git a/R/demean.R b/R/demean.R
index 0d36f5a54..8e5dcfe05 100644
--- a/R/demean.R
+++ b/R/demean.R
@@ -281,12 +281,13 @@ degroup <- function(x,
not_found <- setdiff(select, colnames(x))
if (length(not_found) && isTRUE(verbose)) {
- insight::print_color(sprintf(
- "%i variables were not found in the dataset: %s\n",
- length(not_found),
- paste0(not_found, collapse = ", ")
- ),
- color = "red"
+ insight::print_color(
+ sprintf(
+ "%i variables were not found in the dataset: %s\n",
+ length(not_found),
+ paste0(not_found, collapse = ", ")
+ ),
+ color = "red"
)
}
diff --git a/R/standardize.models.R b/R/standardize.models.R
index 6701924c2..158827175 100644
--- a/R/standardize.models.R
+++ b/R/standardize.models.R
@@ -168,12 +168,13 @@ standardize.default <- function(x,
# can't std data$var variables
if (any(doller_vars <- grepl("(.*)\\$(.*)", do_standardize))) {
doller_vars <- colnames(data)[doller_vars]
- warning(insight::format_message(
- "Unable to standardize variables evaluated in the environment (i.e., not in `data`).",
- "The following variables will not be standardizd:",
- paste0(doller_vars, collapse = ", ")
- ),
- call. = FALSE
+ warning(
+ insight::format_message(
+ "Unable to standardize variables evaluated in the environment (i.e., not in `data`).",
+ "The following variables will not be standardizd:",
+ paste0(doller_vars, collapse = ", ")
+ ),
+ call. = FALSE
)
do_standardize <- setdiff(do_standardize, doller_vars)
dont_standardize <- c(dont_standardize, doller_vars)
@@ -277,11 +278,12 @@ standardize.brmsfit <- function(x,
...) {
data_std <- NULL # needed to avoid note
if (insight::is_multivariate(x)) {
- stop(insight::format_message(
- "multivariate brmsfit models not supported.",
- "As an alternative: you may standardize your data (and adjust your priors), and re-fit the model."
- ),
- call. = FALSE
+ stop(
+ insight::format_message(
+ "multivariate brmsfit models not supported.",
+ "As an alternative: you may standardize your data (and adjust your priors), and re-fit the model."
+ ),
+ call. = FALSE
)
}
@@ -380,11 +382,12 @@ standardize.mediate <- function(x,
# }
if (verbose && !all(c(control.value, treat.value) %in% c(0, 1))) {
- warning(insight::format_message(
- "Control and treat values are not 0 and 1, and have not been re-scaled.",
- "Interpret results with caution."
- ),
- call. = FALSE
+ warning(
+ insight::format_message(
+ "Control and treat values are not 0 and 1, and have not been re-scaled.",
+ "Interpret results with caution."
+ ),
+ call. = FALSE
)
}
@@ -453,11 +456,12 @@ standardize.biglm <- standardize.wbm
.safe_to_standardize_response <- function(info, verbose = TRUE) {
if (is.null(info)) {
if (verbose) {
- warning(insight::format_message(
- "Unable to verify if response should not be standardized.",
- "Response will be standardized."
- ),
- immediate. = TRUE, call. = FALSE
+ warning(
+ insight::format_message(
+ "Unable to verify if response should not be standardized.",
+ "Response will be standardized."
+ ),
+ immediate. = TRUE, call. = FALSE
)
}
return(TRUE)
@@ -507,10 +511,11 @@ standardize.biglm <- standardize.wbm
msg1 <- sprintf("Standardization of parameters not possible for models of class '%s'.", class)
}
- stop(insight::format_message(
- msg1,
- "Try instead to standardize the data (standardize(data)) and refit the model manually."
- ),
- call. = FALSE
+ stop(
+ insight::format_message(
+ msg1,
+ "Try instead to standardize the data (standardize(data)) and refit the model manually."
+ ),
+ call. = FALSE
)
}
diff --git a/README.Rmd b/README.Rmd
index 6a314efc0..1c9c1d000 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -2,7 +2,7 @@
output: github_document
---
-# `datawizard`: Easy Data Wrangling
+# `datawizard`: Easy Data Wrangling and Statistical Transformations
```{r, echo=FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(
@@ -21,9 +21,6 @@ library(datawizard)
[![downloads](http://cranlogs.r-pkg.org/badges/datawizard)](https://cran.r-project.org/package=datawizard)
[![total](https://cranlogs.r-pkg.org/badges/grand-total/datawizard)](https://cranlogs.r-pkg.org/) [![status](https://tinyverse.netlify.com/badge/datawizard)](https://CRAN.R-project.org/package=datawizard)
-
-
-
@@ -36,10 +33,15 @@ library(datawizard)
Most courses and tutorials about statistical modeling assume that you are working with a clean and tidy dataset. In practice, however, a major part of doing statistical modeling is preparing your data--cleaning up values, creating new columns, reshaping the dataset, or transforming some variables. `{datawizard}` provides easy to use tools to perform these common, critical, and sometimes tedious data preparation tasks.
+
+
+
+
+
# Installation
-[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/datawizard)](https://cran.r-project.org/package=datawizard) [![insight status badge](https://easystats.r-universe.dev/badges/datawizard)](https://easystats.r-universe.dev) [![R check](https://github.com/easystats/datawizard/workflows/R-check/badge.svg?branch=master)](https://github.com/easystats/datawizard/actions)
+[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/datawizard)](https://cran.r-project.org/package=datawizard) [![insight status badge](https://easystats.r-universe.dev/badges/datawizard)](https://easystats.r-universe.dev) [![R check](https://github.com/easystats/datawizard/workflows/R-check/badge.svg?branch=main)](https://github.com/easystats/datawizard/actions)
Type | Source | Command
---|---|---
diff --git a/README.md b/README.md
index ef4a690c3..e205f0570 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,11 @@
-# `datawizard`: Easy Data Wrangling
+# `datawizard`: Easy Data Wrangling and Statistical Transformations
[![publication](https://img.shields.io/badge/Cite-Unpublished-yellow)](https://github.com/easystats/datawizard/blob/master/inst/CITATION)
[![downloads](http://cranlogs.r-pkg.org/badges/datawizard)](https://cran.r-project.org/package=datawizard)
[![total](https://cranlogs.r-pkg.org/badges/grand-total/datawizard)](https://cranlogs.r-pkg.org/)
[![status](https://tinyverse.netlify.com/badge/datawizard)](https://CRAN.R-project.org/package=datawizard)
-
-
@@ -26,13 +24,19 @@ values, creating new columns, reshaping the dataset, or transforming
some variables. `{datawizard}` provides easy to use tools to perform
these common, critical, and sometimes tedious data preparation tasks.
+
+
+
+
+
+
# Installation
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/datawizard)](https://cran.r-project.org/package=datawizard)
[![insight status
badge](https://easystats.r-universe.dev/badges/datawizard)](https://easystats.r-universe.dev)
[![R
-check](https://github.com/easystats/datawizard/workflows/R-check/badge.svg?branch=master)](https://github.com/easystats/datawizard/actions)
+check](https://github.com/easystats/datawizard/workflows/R-check/badge.svg?branch=main)](https://github.com/easystats/datawizard/actions)
| Type | Source | Command |
|-------------|------------|------------------------------------------------------------------------------|
@@ -49,17 +53,18 @@ citation("datawizard")
To cite datawizard in publications use:
- Makowski, Lüdecke, Patil, Ben-Shachar, & Wiernik (2021). datawizard:
- Easy Data Wrangling. CRAN. Available from
+ Patil, Makowski, Ben-Shachar, Wiernik, Bacher, & Lüdecke (2022).
+ datawizard: An R Package for Easy Data Preparation and Statistical
+ Transformations. CRAN. Available from
https://easystats.github.io/datawizard/
A BibTeX entry for LaTeX users is
@Article{,
- title = {datawizard: Easy Data Wrangling},
- author = {Dominique Makowski and Daniel Lüdecke and Indrajeet Patil and Mattan S. Ben-Shachar and Brenton M. Wiernik},
+ title = {datawizard: An R Package for Easy Data Preparation and Statistical Transformations},
+ author = {Indrajeet Patil and Dominique Makowski and Mattan S. Ben-Shachar and Brenton M. Wiernik and Etienne Bacher and Daniel Lüdecke},
journal = {CRAN},
- year = {2021},
+ year = {2022},
note = {R package},
url = {https://easystats.github.io/datawizard/},
}
diff --git a/inst/CITATION b/inst/CITATION
index aac9c6d84..5b20b4129 100644
--- a/inst/CITATION
+++ b/inst/CITATION
@@ -1,14 +1,14 @@
bibentry(
bibtype="Article",
- title="datawizard: Easy Data Wrangling",
- author=c(person("Dominique", "Makowski"), person("Daniel", "Lüdecke"), person("Indrajeet", "Patil"), person("Mattan S.", "Ben-Shachar"), person("Brenton M.", "Wiernik")),
+ title="datawizard: An R Package for Easy Data Preparation and Statistical Transformations",
+ author=c(person("Indrajeet", "Patil"), person("Dominique", "Makowski"), person("Mattan S.", "Ben-Shachar"), person("Brenton M.", "Wiernik"), person("Etienne", "Bacher"), person("Daniel", "Lüdecke")),
journal="CRAN",
- year="2021",
+ year="2022",
note="R package",
url="https://easystats.github.io/datawizard/",
textVersion =
- paste("Makowski, Lüdecke, Patil, Ben-Shachar, & Wiernik (2021). datawizard: Easy Data Wrangling. CRAN.",
+ paste("Patil, Makowski, Ben-Shachar, Wiernik, Bacher, & Lüdecke (2022). datawizard: An R Package for Easy Data Preparation and Statistical Transformations. CRAN.",
"Available from https://easystats.github.io/datawizard/"
),
mheader = "To cite datawizard in publications use:"
diff --git a/man/data_to_long.Rd b/man/data_to_long.Rd
index 2e4757f46..0d24cb91c 100644
--- a/man/data_to_long.Rd
+++ b/man/data_to_long.Rd
@@ -151,16 +151,15 @@ if (require("psych")) {
rows_to = "Participant"
)
-if(require("tidyr")) {
- reshape_longer(
- tidyr::who,
- select = new_sp_m014:newrel_f65,
- names_to = c("diagnosis", "gender", "age"),
- names_pattern = "new_?(.*)_(.)(.*)",
- values_to = "count"
- )
-}
-
+ if (require("tidyr")) {
+ reshape_longer(
+ tidyr::who,
+ select = new_sp_m014:newrel_f65,
+ names_to = c("diagnosis", "gender", "age"),
+ names_pattern = "new_?(.*)_(.)(.*)",
+ values_to = "count"
+ )
+ }
}
}
diff --git a/paper/paper.Rmd b/paper/paper.Rmd
index a1917cbdf..664c36058 100644
--- a/paper/paper.Rmd
+++ b/paper/paper.Rmd
@@ -99,7 +99,7 @@ We will look at one example function that converts data in wide format to tidy/l
```{r}
stocks <- data.frame(
- time = as.Date('2009-01-01') + 0:4,
+ time = as.Date("2009-01-01") + 0:4,
X = rnorm(5, 0, 1),
Y = rnorm(5, 0, 2)
)
diff --git a/tests/testthat/test-data_group.R b/tests/testthat/test-data_group.R
index 360523358..e6c0d7159 100644
--- a/tests/testthat/test-data_group.R
+++ b/tests/testthat/test-data_group.R
@@ -4,26 +4,27 @@ test_that("data_group attributes", {
x <- data_group(efc, "c172code")
expect_equal(
attributes(x)$groups,
- structure(list(
- c172code = c(1, 2, 3, NA),
- .rows = list(
- c(3L, 14L, 30L, 32L, 36L, 77L, 91L, 99L),
- c(
- 1L, 2L, 4L, 5L, 6L, 7L, 8L, 10L, 11L, 12L, 16L, 17L, 18L,
- 21L, 22L, 23L, 24L, 25L, 26L, 28L, 29L, 31L, 33L, 34L, 35L,
- 37L, 38L, 39L, 40L, 42L, 44L, 45L, 46L, 47L, 50L, 51L, 52L,
- 53L, 54L, 56L, 57L, 59L, 60L, 62L, 65L, 68L, 69L, 71L, 72L,
- 73L, 76L, 78L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L,
- 90L, 92L, 93L, 96L, 100L
- ),
- c(
- 13L, 15L, 19L, 20L, 27L, 41L, 43L, 55L, 58L, 64L, 66L, 67L,
- 74L, 75L, 79L, 89L
- ),
- c(9L, 48L, 49L, 61L, 63L, 70L, 94L, 95L, 97L, 98L)
- )
- ),
- row.names = c(2L, 1L, 4L, 3L), class = "data.frame", .drop = TRUE
+ structure(
+ list(
+ c172code = c(1, 2, 3, NA),
+ .rows = list(
+ c(3L, 14L, 30L, 32L, 36L, 77L, 91L, 99L),
+ c(
+ 1L, 2L, 4L, 5L, 6L, 7L, 8L, 10L, 11L, 12L, 16L, 17L, 18L,
+ 21L, 22L, 23L, 24L, 25L, 26L, 28L, 29L, 31L, 33L, 34L, 35L,
+ 37L, 38L, 39L, 40L, 42L, 44L, 45L, 46L, 47L, 50L, 51L, 52L,
+ 53L, 54L, 56L, 57L, 59L, 60L, 62L, 65L, 68L, 69L, 71L, 72L,
+ 73L, 76L, 78L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L,
+ 90L, 92L, 93L, 96L, 100L
+ ),
+ c(
+ 13L, 15L, 19L, 20L, 27L, 41L, 43L, 55L, 58L, 64L, 66L, 67L,
+ 74L, 75L, 79L, 89L
+ ),
+ c(9L, 48L, 49L, 61L, 63L, 70L, 94L, 95L, 97L, 98L)
+ )
+ ),
+ row.names = c(2L, 1L, 4L, 3L), class = "data.frame", .drop = TRUE
)
)
expect_s3_class(x, "grouped_df")
diff --git a/tests/testthat/test-data_recode.R b/tests/testthat/test-data_recode.R
index b025b2ae1..a18e0d360 100644
--- a/tests/testthat/test-data_recode.R
+++ b/tests/testthat/test-data_recode.R
@@ -125,14 +125,15 @@ test_that("recode data.frame", {
)
expect_equal(
out,
- structure(list(
- x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
- y = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L),
- .Label = c("x", "y"),
- class = "factor"
- )
- ),
- row.names = c(NA, 15L), class = "data.frame"
+ structure(
+ list(
+ x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
+ y = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L),
+ .Label = c("x", "y"),
+ class = "factor"
+ )
+ ),
+ row.names = c(NA, 15L), class = "data.frame"
),
ignore_attr = TRUE
)
@@ -143,14 +144,15 @@ test_that("recode data.frame", {
)
expect_equal(
out,
- structure(list(
- x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
- y = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L),
- .Label = c("x", "y"),
- class = "factor"
- )
- ),
- row.names = c(NA, 15L), class = "data.frame"
+ structure(
+ list(
+ x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
+ y = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L),
+ .Label = c("x", "y"),
+ class = "factor"
+ )
+ ),
+ row.names = c(NA, 15L), class = "data.frame"
),
ignore_attr = TRUE
)
@@ -162,14 +164,15 @@ test_that("recode data.frame", {
)
expect_equal(
out,
- structure(list(
- x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
- y = structure(c(1L, 1L, 1L, 3L, 2L, 3L, 2L, 1L, 2L, 3L, 2L, 1L, 3L, 3L, 1L),
- .Label = c("a", "b", "c"),
- class = "factor"
- )
- ),
- row.names = c(NA, 15L), class = "data.frame"
+ structure(
+ list(
+ x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
+ y = structure(c(1L, 1L, 1L, 3L, 2L, 3L, 2L, 1L, 2L, 3L, 2L, 1L, 3L, 3L, 1L),
+ .Label = c("a", "b", "c"),
+ class = "factor"
+ )
+ ),
+ row.names = c(NA, 15L), class = "data.frame"
),
ignore_attr = TRUE
)
@@ -241,14 +244,15 @@ test_that("recode data.frame", {
)
expect_equal(
out,
- structure(list(
- x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
- y = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L),
- .Label = c("x", "y"),
- class = "factor"
- )
- ),
- row.names = c(NA, 15L), class = "data.frame"
+ structure(
+ list(
+ x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
+ y = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L),
+ .Label = c("x", "y"),
+ class = "factor"
+ )
+ ),
+ row.names = c(NA, 15L), class = "data.frame"
),
ignore_attr = TRUE
)
@@ -259,14 +263,15 @@ test_that("recode data.frame", {
)
expect_equal(
out,
- structure(list(
- x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
- y = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L),
- .Label = c("x", "y"),
- class = "factor"
- )
- ),
- row.names = c(NA, 15L), class = "data.frame"
+ structure(
+ list(
+ x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
+ y = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L),
+ .Label = c("x", "y"),
+ class = "factor"
+ )
+ ),
+ row.names = c(NA, 15L), class = "data.frame"
),
ignore_attr = TRUE
)
@@ -278,14 +283,15 @@ test_that("recode data.frame", {
)
expect_equal(
out,
- structure(list(
- x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
- y = structure(c(1L, 1L, 1L, 3L, 2L, 3L, 2L, 1L, 2L, 3L, 2L, 1L, 3L, 3L, 1L),
- .Label = c("a", "b", "c"),
- class = "factor"
- )
- ),
- row.names = c(NA, 15L), class = "data.frame"
+ structure(
+ list(
+ x = c(1, 1, 1, 1, 1, NA, 2, 0, 1, 1, NA, 1, 1, 0, 2),
+ y = structure(c(1L, 1L, 1L, 3L, 2L, 3L, 2L, 1L, 2L, 3L, 2L, 1L, 3L, 3L, 1L),
+ .Label = c("a", "b", "c"),
+ class = "factor"
+ )
+ ),
+ row.names = c(NA, 15L), class = "data.frame"
),
ignore_attr = TRUE
)
diff --git a/tests/testthat/test-replace_nan_inf.R b/tests/testthat/test-replace_nan_inf.R
index 638513e90..af94c229f 100644
--- a/tests/testthat/test-replace_nan_inf.R
+++ b/tests/testthat/test-replace_nan_inf.R
@@ -15,12 +15,13 @@ test_that("extract from data frame", {
expect_equal(
replace_nan_inf(df),
- structure(list(
- x = c(1, NA, 5, NA, 2, NA),
- y = c(3, NA, 4, NA, 6, 7)
- ),
- row.names = c(NA, -6L),
- class = "data.frame"
+ structure(
+ list(
+ x = c(1, NA, 5, NA, 2, NA),
+ y = c(3, NA, 4, NA, 6, 7)
+ ),
+ row.names = c(NA, -6L),
+ class = "data.frame"
)
)
})