Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

degroup() for cross-classified data #521

Merged
merged 24 commits into from
Jul 1, 2024
Merged

Conversation

strengejacke
Copy link
Member

Fixes #520

@strengejacke
Copy link
Member Author

Tagging @jmgirard, you may review this PR.

@strengejacke
Copy link
Member Author

@etiennebacher Currently, when a variable name was misspelled, we simply ignore it and print a message (not even a warning!). Should we error here?

library(datawizard)
data(efc, package = "datawizard")
degroup(
  efc,
  select = c("c12hour", "neg_c_8"),
  by = c("e42dep", "c173code"),
  suffix_demean = "_within"
) |> head()
#> Variables "neg_c_8" and "c173code" were not found in the dataset.
#>   Did you mean one of "neg_c_7" or "c172code"?
#>   c12hour_between c12hour_within
#> 1         52.7500      -36.75000
#> 2         52.7500       95.25000
#> 3         52.7500       17.25000
#> 4              NA             NA
#> 5        106.9683       61.03175
#> 6        106.9683      -90.96825

Created on 2024-06-27 with reprex v2.1.0

NEWS.md Outdated Show resolved Hide resolved
R/demean.R Outdated Show resolved Hide resolved
R/demean.R Show resolved Hide resolved
R/demean.R Outdated Show resolved Hide resolved
tests/testthat/test-demean.R Outdated Show resolved Hide resolved
@strengejacke
Copy link
Member Author

Ok, the implementation of nested designs seems to be wrong (see #520 (comment)). I would remove that code and wait until we know how to do this correctly.

@strengejacke
Copy link
Member Author

I think this is ready to be merged?

@etiennebacher
Copy link
Member

There is still some discussion going on in #520, does this PR fix everything? If not, you might want to remove the "fixes #520" in the first post.

I just want to do a second pass this afternoon or tomorrow since there were many commits since the last review.

@strengejacke
Copy link
Member Author

It works for the cross-classified case, as requested in #520. The extension to nested data structures came to my mind, but seems to be less trivial. I think this can be done later. The docs clearly state that degroup() works for the cross-classified, but not nested case right now.

@strengejacke
Copy link
Member Author

I just want to do a second pass this afternoon or tomorrow since there were many commits since the last review.

That was an attempt to see if nested structures would work, but I then reverted the changed. So it's actually less new code you have to review ;-)

Copy link
Member

@etiennebacher etiennebacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @strengejacke !

@etiennebacher etiennebacher merged commit 8658c8a into main Jul 1, 2024
16 checks passed
@etiennebacher etiennebacher deleted the strengejacke/issue520 branch July 1, 2024 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

degroup() for cross-classified data
2 participants