Skip to content

Commit

Permalink
Add Kish-method to rescale_weights (#575)
Browse files Browse the repository at this point in the history
* Add Kish-method to `rescale_weights`

* fix

* fix

* lintr

* fix

* fix

* fix

* docs

* docs

* remove experimental code for now

* docs

* fix, add tests

* fix, add tests

* add tests

* add tests

* styler

* lintr, wordlist

* docs

* fix

* docs, tests, rename into rescaled_weights

* docs

* Update R/rescale_weights.R

Co-authored-by: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com>

* Update NEWS.md

Co-authored-by: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com>

* Update R/rescale_weights.R

Co-authored-by: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com>

* address comments

* fix test

* address comments (docs)

* implement by

* implement `by`

* typo

* update examples

* docs

* fix

* fix

* fix

* desc

* fix, add tests

* examples

* docs

* docs

* tests

* add tests

* typo

---------

Co-authored-by: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com>
  • Loading branch information
strengejacke and etiennebacher authored Dec 31, 2024
1 parent ced29bf commit 08128ff
Show file tree
Hide file tree
Showing 9 changed files with 682 additions and 208 deletions.
2 changes: 1 addition & 1 deletion 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.13.0.21
Version: 0.13.0.22
Authors@R: c(
person("Indrajeet", "Patil", , "patilindrajeet.science@gmail.com", role = "aut",
comment = c(ORCID = "0000-0003-1995-6531")),
Expand Down
12 changes: 11 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,29 @@ BREAKING CHANGES AND DEPRECATIONS
- if `select` (previously `pattern`) is a named vector, then all elements
must be named, e.g. `c(length = "Sepal.Length", "Sepal.Width")` errors.

* Order of arguments `by` and `probability_weights` in `rescale_weights()` has
changed, because for `method = "kish"`, the `by` argument is optional.

* The name of the rescaled weights variables in `rescale_weights()` have been
renamed. `pweights_a` and `pweights_b` are now named `rescaled_weights_a`
and `rescaled_weights_b`.

* `print()` methods for `data_tabulate()` with multiple sub-tables (i.e. when
length of `by` was > 1) were revised. Now, an integrated table instead of
multiple tables is returned. Furthermore, `print_html()` did not work, which
was also fixed now.

* `demean()` (and `degroup()`) gets an `append` argument that defaults to `TRUE`,
to append the centered variabled to the original data frame, instead of
to append the centered variables to the original data frame, instead of
returning the de- and group-meaned variables only. Use `append = FALSE` to
for the previous default behaviour (i.e. only returning the newly created
variables).

CHANGES

* `rescale_weights()` gets a `method` argument, to choose method to rescale
weights. Options are `"carle"` (the default) and `"kish"`.

* The `select` argument, which is available in different functions to select
variables, can now also be a character vector with quoted variable names,
including a colon to indicate a range of several variables (e.g. `"cyl:gear"`).
Expand Down
2 changes: 1 addition & 1 deletion R/data_arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ data_arrange.default <- function(data, select = NULL, safe = TRUE) {
select <- gsub("^-", "", select)

# check for variables that are not in data
dont_exist <- select[which(!select %in% names(data))]
dont_exist <- setdiff(select, colnames(data))

if (length(dont_exist) > 0) {
if (safe) {
Expand Down
Loading

0 comments on commit 08128ff

Please sign in to comment.