Skip to content

Commit

Permalink
same as JOSS cite; style; README cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Aug 17, 2022
1 parent 476e47a commit 34cf6bf
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 146 deletions.
3 changes: 2 additions & 1 deletion R/convert_na_to.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
19 changes: 9 additions & 10 deletions R/data_reshape.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
#' )
#' }
#' }
#' }
#'
Expand Down
13 changes: 7 additions & 6 deletions R/demean.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
}

Expand Down
57 changes: 31 additions & 26 deletions R/standardize.models.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
}

Expand Down Expand Up @@ -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
)
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
}
12 changes: 7 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
output: github_document
---

# `datawizard`: Easy Data Wrangling <img src='man/figures/logo.png' align="right" height="139" />
# `datawizard`: Easy Data Wrangling and Statistical Transformations <img src='man/figures/logo.png' align="right" height="139" />

```{r, echo=FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(
Expand All @@ -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)


<img src='https://media.giphy.com/media/VcizxCUIgaKpa/giphy.gif' width="200" align = "right"/>

<!-- ***:sparkles: Hockety pockety wockety wack, prepare this data forth and back*** -->

<!-- ***Hockety pockety wockety wock, messy data is in shock*** -->
Expand All @@ -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.

</br>

<img src='https://media.giphy.com/media/VcizxCUIgaKpa/giphy.gif' width="300"/>

</br>

# 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
---|---|---
Expand Down
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@

# `datawizard`: Easy Data Wrangling <img src='man/figures/logo.png' align="right" height="139" />
# `datawizard`: Easy Data Wrangling and Statistical Transformations <img src='man/figures/logo.png' align="right" height="139" />

[![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)

<img src='https://media.giphy.com/media/VcizxCUIgaKpa/giphy.gif' width="200" align = "right"/>

<!-- ***:sparkles: Hockety pockety wockety wack, prepare this data forth and back*** -->
<!-- ***Hockety pockety wockety wock, messy data is in shock*** -->
<!-- ***Hockety pockety wockety woss, you can cite i-it from JOSS*** <sup>(soon)</sup> -->
Expand All @@ -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.

</br>

<img src='https://media.giphy.com/media/VcizxCUIgaKpa/giphy.gif' width="300"/>

</br>

# 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 |
|-------------|------------|------------------------------------------------------------------------------|
Expand All @@ -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/},
}
Expand Down
8 changes: 4 additions & 4 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -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:"
Expand Down
19 changes: 9 additions & 10 deletions man/data_to_long.Rd

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

2 changes: 1 addition & 1 deletion paper/paper.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
41 changes: 21 additions & 20 deletions tests/testthat/test-data_group.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading

0 comments on commit 34cf6bf

Please sign in to comment.