From 9bd0005a580029b88eddb327db0f221ca503765f Mon Sep 17 00:00:00 2001 From: etiennebacher Date: Tue, 17 Dec 2024 16:34:34 +0100 Subject: [PATCH 1/3] bump version --- DESCRIPTION | 3 +-- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 68cfb6741..8501556ad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: datawizard Title: Easy Data Wrangling and Statistical Transformations -Version: 0.13.0.19 +Version: 1.0.0 Authors@R: c( person("Indrajeet", "Patil", , "patilindrajeet.science@gmail.com", role = "aut", comment = c(ORCID = "0000-0003-1995-6531")), @@ -76,4 +76,3 @@ RoxygenNote: 7.3.2 Config/testthat/edition: 3 Config/testthat/parallel: true Config/Needs/website: easystats/easystatstemplate -Remotes: easystats/insight diff --git a/NEWS.md b/NEWS.md index 35e549ffa..8e9c50d70 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# datawizard (development) +# datawizard 1.0.0 BREAKING CHANGES AND DEPRECATIONS From c189e31c56a796b92d597468b6c029048de588cc Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 17 Dec 2024 18:38:12 +0100 Subject: [PATCH 2/3] docs --- R/rescale_weights.R | 42 ++++++++++++++++++++---------------------- man/rescale_weights.Rd | 42 +++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/R/rescale_weights.R b/R/rescale_weights.R index ec0c75616..1f528c77d 100644 --- a/R/rescale_weights.R +++ b/R/rescale_weights.R @@ -60,32 +60,30 @@ #' - Asparouhov T. (2006). General Multi-Level Modeling with Sampling #' Weights. Communications in Statistics - Theory and Methods 35: 439-460 #' -#' @examples -#' if (require("lme4")) { -#' data(nhanes_sample) -#' head(rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR")) +#' @examplesIf insight::check_if_installed("lme4", quietly = TRUE) +#' data(nhanes_sample) +#' head(rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR")) #' -#' # also works with multiple group-variables -#' head(rescale_weights(nhanes_sample, c("SDMVSTRA", "SDMVPSU"), "WTINT2YR")) +#' # also works with multiple group-variables +#' head(rescale_weights(nhanes_sample, c("SDMVSTRA", "SDMVPSU"), "WTINT2YR")) #' -#' # or nested structures. -#' x <- rescale_weights( -#' data = nhanes_sample, -#' by = c("SDMVSTRA", "SDMVPSU"), -#' probability_weights = "WTINT2YR", -#' nest = TRUE -#' ) -#' head(x) +#' # or nested structures. +#' x <- rescale_weights( +#' data = nhanes_sample, +#' by = c("SDMVSTRA", "SDMVPSU"), +#' probability_weights = "WTINT2YR", +#' nest = TRUE +#' ) +#' head(x) #' -#' nhanes_sample <- rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR") +#' nhanes_sample <- rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR") #' -#' glmer( -#' total ~ factor(RIAGENDR) * (log(age) + factor(RIDRETH1)) + (1 | SDMVPSU), -#' family = poisson(), -#' data = nhanes_sample, -#' weights = pweights_a -#' ) -#' } +#' lme4::glmer( +#' total ~ factor(RIAGENDR) * (log(age) + factor(RIDRETH1)) + (1 | SDMVPSU), +#' family = poisson(), +#' data = nhanes_sample, +#' weights = pweights_a +#' ) #' @export rescale_weights <- function(data, by, probability_weights, nest = FALSE) { if (inherits(by, "formula")) { diff --git a/man/rescale_weights.Rd b/man/rescale_weights.Rd index d9651decb..d2eddc894 100644 --- a/man/rescale_weights.Rd +++ b/man/rescale_weights.Rd @@ -63,31 +63,31 @@ design, or group and PSU as varying intercepts), depending on the survey design that should be mimicked. } \examples{ -if (require("lme4")) { - data(nhanes_sample) - head(rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR")) +\dontshow{if (insight::check_if_installed("lme4", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +data(nhanes_sample) +head(rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR")) - # also works with multiple group-variables - head(rescale_weights(nhanes_sample, c("SDMVSTRA", "SDMVPSU"), "WTINT2YR")) +# also works with multiple group-variables +head(rescale_weights(nhanes_sample, c("SDMVSTRA", "SDMVPSU"), "WTINT2YR")) - # or nested structures. - x <- rescale_weights( - data = nhanes_sample, - by = c("SDMVSTRA", "SDMVPSU"), - probability_weights = "WTINT2YR", - nest = TRUE - ) - head(x) +# or nested structures. +x <- rescale_weights( + data = nhanes_sample, + by = c("SDMVSTRA", "SDMVPSU"), + probability_weights = "WTINT2YR", + nest = TRUE +) +head(x) - nhanes_sample <- rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR") +nhanes_sample <- rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR") - glmer( - total ~ factor(RIAGENDR) * (log(age) + factor(RIDRETH1)) + (1 | SDMVPSU), - family = poisson(), - data = nhanes_sample, - weights = pweights_a - ) -} +lme4::glmer( + total ~ factor(RIAGENDR) * (log(age) + factor(RIDRETH1)) + (1 | SDMVPSU), + family = poisson(), + data = nhanes_sample, + weights = pweights_a +) +\dontshow{\}) # examplesIf} } \references{ \itemize{ From 260f0ebd355adb7eef3da0fac9cb5b411ac3a04f Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 18 Dec 2024 12:25:26 +0100 Subject: [PATCH 3/3] Revert "docs" This reverts commit c189e31c56a796b92d597468b6c029048de588cc. --- R/rescale_weights.R | 42 ++++++++++++++++++++++-------------------- man/rescale_weights.Rd | 42 +++++++++++++++++++++--------------------- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/R/rescale_weights.R b/R/rescale_weights.R index 1f528c77d..ec0c75616 100644 --- a/R/rescale_weights.R +++ b/R/rescale_weights.R @@ -60,30 +60,32 @@ #' - Asparouhov T. (2006). General Multi-Level Modeling with Sampling #' Weights. Communications in Statistics - Theory and Methods 35: 439-460 #' -#' @examplesIf insight::check_if_installed("lme4", quietly = TRUE) -#' data(nhanes_sample) -#' head(rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR")) +#' @examples +#' if (require("lme4")) { +#' data(nhanes_sample) +#' head(rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR")) #' -#' # also works with multiple group-variables -#' head(rescale_weights(nhanes_sample, c("SDMVSTRA", "SDMVPSU"), "WTINT2YR")) +#' # also works with multiple group-variables +#' head(rescale_weights(nhanes_sample, c("SDMVSTRA", "SDMVPSU"), "WTINT2YR")) #' -#' # or nested structures. -#' x <- rescale_weights( -#' data = nhanes_sample, -#' by = c("SDMVSTRA", "SDMVPSU"), -#' probability_weights = "WTINT2YR", -#' nest = TRUE -#' ) -#' head(x) +#' # or nested structures. +#' x <- rescale_weights( +#' data = nhanes_sample, +#' by = c("SDMVSTRA", "SDMVPSU"), +#' probability_weights = "WTINT2YR", +#' nest = TRUE +#' ) +#' head(x) #' -#' nhanes_sample <- rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR") +#' nhanes_sample <- rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR") #' -#' lme4::glmer( -#' total ~ factor(RIAGENDR) * (log(age) + factor(RIDRETH1)) + (1 | SDMVPSU), -#' family = poisson(), -#' data = nhanes_sample, -#' weights = pweights_a -#' ) +#' glmer( +#' total ~ factor(RIAGENDR) * (log(age) + factor(RIDRETH1)) + (1 | SDMVPSU), +#' family = poisson(), +#' data = nhanes_sample, +#' weights = pweights_a +#' ) +#' } #' @export rescale_weights <- function(data, by, probability_weights, nest = FALSE) { if (inherits(by, "formula")) { diff --git a/man/rescale_weights.Rd b/man/rescale_weights.Rd index d2eddc894..d9651decb 100644 --- a/man/rescale_weights.Rd +++ b/man/rescale_weights.Rd @@ -63,31 +63,31 @@ design, or group and PSU as varying intercepts), depending on the survey design that should be mimicked. } \examples{ -\dontshow{if (insight::check_if_installed("lme4", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -data(nhanes_sample) -head(rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR")) +if (require("lme4")) { + data(nhanes_sample) + head(rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR")) -# also works with multiple group-variables -head(rescale_weights(nhanes_sample, c("SDMVSTRA", "SDMVPSU"), "WTINT2YR")) + # also works with multiple group-variables + head(rescale_weights(nhanes_sample, c("SDMVSTRA", "SDMVPSU"), "WTINT2YR")) -# or nested structures. -x <- rescale_weights( - data = nhanes_sample, - by = c("SDMVSTRA", "SDMVPSU"), - probability_weights = "WTINT2YR", - nest = TRUE -) -head(x) + # or nested structures. + x <- rescale_weights( + data = nhanes_sample, + by = c("SDMVSTRA", "SDMVPSU"), + probability_weights = "WTINT2YR", + nest = TRUE + ) + head(x) -nhanes_sample <- rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR") + nhanes_sample <- rescale_weights(nhanes_sample, "SDMVSTRA", "WTINT2YR") -lme4::glmer( - total ~ factor(RIAGENDR) * (log(age) + factor(RIDRETH1)) + (1 | SDMVPSU), - family = poisson(), - data = nhanes_sample, - weights = pweights_a -) -\dontshow{\}) # examplesIf} + glmer( + total ~ factor(RIAGENDR) * (log(age) + factor(RIDRETH1)) + (1 | SDMVPSU), + family = poisson(), + data = nhanes_sample, + weights = pweights_a + ) +} } \references{ \itemize{