Skip to content

Commit

Permalink
degroup() for cross-classified data (#521)
Browse files Browse the repository at this point in the history
* degroup() for cross-classified data
Fixes #520

* draft

* fix

* comment

* add tests

* news

* newslione

* wordlist

* checks

* better message

* styler complains

* review comments

* fix

* update snapshots

* docs

* add experimental feature

* warning

* remove note

* fix

* add test for nested structures

* test warning

* remove code for nested structure

* docs

---------

Co-authored-by: Etienne Bacher <[email protected]>
  • Loading branch information
strengejacke and etiennebacher authored Jul 1, 2024
1 parent 8d120c8 commit 8658c8a
Show file tree
Hide file tree
Showing 8 changed files with 464 additions and 244 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.11.0.4
Version: 0.11.0.5
Authors@R: c(
person("Indrajeet", "Patil", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0003-1995-6531", Twitter = "@patilindrajeets")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ CHANGES
frame, where the first column contains name of the variable for which
frequencies were calculated, and the second column contains the frequency table.

* `demean()` (and `degroup()`) now also work for cross-classified designs, or
more generally, for data with multiple grouping or cluster variables (i.e.
`by` can now specify more than one variable).

# datawizard 0.11.0

BREAKING CHANGES
Expand Down
362 changes: 206 additions & 156 deletions R/demean.R

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ CMD
Carle
Catran
Crosstables
Dhaliwal
Disaggregating
DOI
De
Dom
Expand All @@ -16,6 +18,7 @@ GLMM
Gelman
Giesecke
Giesselmann
Guo
Heisig
Herrington
Hoffmann
Expand Down Expand Up @@ -79,6 +82,7 @@ midhinge
modelbased
modelling
nd
panelr
partialization
patilindrajeets
platykurtic
Expand Down
180 changes: 110 additions & 70 deletions man/demean.Rd

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

28 changes: 14 additions & 14 deletions tests/testthat/_snaps/demean.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@
Code
head(x)
Output
Sepal.Length_between Species_between binary_between Species_setosa_between
1 5.925000 0.850000 0.375 0.4250000
2 5.925000 0.850000 0.375 0.4250000
3 5.925000 0.850000 0.375 0.4250000
4 5.862222 1.133333 0.400 0.2888889
5 5.925000 0.850000 0.375 0.4250000
6 5.862222 1.133333 0.400 0.2888889
Sepal.Length_between binary_between Species_between Species_setosa_between
1 5.925000 0.375 0.850000 0.4250000
2 5.925000 0.375 0.850000 0.4250000
3 5.925000 0.375 0.850000 0.4250000
4 5.862222 0.400 1.133333 0.2888889
5 5.925000 0.375 0.850000 0.4250000
6 5.862222 0.400 1.133333 0.2888889
Species_versicolor_between Species_virginica_between Sepal.Length_within
1 0.3000000 0.2750000 -0.8250000
2 0.3000000 0.2750000 -1.0250000
3 0.3000000 0.2750000 -1.2250000
4 0.2888889 0.4222222 -1.2622222
5 0.3000000 0.2750000 -0.9250000
6 0.2888889 0.4222222 -0.4622222
Species_within binary_within Species_setosa_within Species_versicolor_within
1 -0.850000 -0.375 0.5750000 -0.3000000
2 -0.850000 0.625 0.5750000 -0.3000000
3 -0.850000 -0.375 0.5750000 -0.3000000
4 -1.133333 0.600 0.7111111 -0.2888889
5 -0.850000 0.625 0.5750000 -0.3000000
6 -1.133333 -0.400 0.7111111 -0.2888889
binary_within Species_within Species_setosa_within Species_versicolor_within
1 -0.375 -0.850000 0.5750000 -0.3000000
2 0.625 -0.850000 0.5750000 -0.3000000
3 -0.375 -0.850000 0.5750000 -0.3000000
4 0.600 -1.133333 0.7111111 -0.2888889
5 0.625 -0.850000 0.5750000 -0.3000000
6 -0.400 -1.133333 0.7111111 -0.2888889
Species_virginica_within
1 -0.2750000
2 -0.2750000
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-center.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ test_that("center, factors (grouped data)", {
poorman::ungroup() %>%
poorman::pull(Species)

manual <- iris %>%
poorman::pull(Species)
manual <- poorman::pull(iris, Species)

expect_identical(datawizard, manual)
})
Expand Down
Loading

0 comments on commit 8658c8a

Please sign in to comment.