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

Adds tidy-method form summary_emm-objects. #691

Merged
merged 6 commits into from Aug 15, 2019
Merged

Adds tidy-method form summary_emm-objects. #691

merged 6 commits into from Aug 15, 2019

Conversation

crsh
Copy link
Contributor

@crsh crsh commented Apr 11, 2019

Currently, the tidy()-methods for various objects from emmeans/lsmeans summarize and subsequently tidy the input. This PR separates these two steps and adds a slightly extended tidier for summary_emm objects (returned by, for example, emmeans::joint_tests()).

@alexpghayes
Copy link
Collaborator

Hey! Thanks for the PR! I don't use emmeans enough to understand what's going on here. Can you give me the big picture motivation behind this change?

@crsh
Copy link
Contributor Author

crsh commented Aug 8, 2019

Hi Alex,

of course! My main motivation for this PR is that emmeans has a function named joint_tests() that provides an ANOVA-like table (rather than testing terms individually):

> fit <- lm(sales1 ~ price1 + price2 + day + store, data = oranges)
> joint_tests_summary <- joint_tests(fit)
> joint_tests_summary

 model term df1 df2 F.ratio p.value
 day          5  23   4.879  0.0035
 store        5  23   2.522  0.0583

The output of joint_tests() is currently not supported by broom because there is no method for summarized emmeans objects:

> class(joint_tests_summary)
[1] "summary_emm" "data.frame" 

Currently the tidy()-methods only apply to non-summarized objects; there is no method for objects of class summary_emm.

By separating the call to summary() from the subsequent tidying, support for summary_emm is straightforward. This PR performs this separation, adds a summary_emm-method, and adds tests to verify that joint_tests()-output is tidied correctly.

Another motivation is that I use tidy() in my package papaja to standardize the input to my function that subsequently typeset the results. For greater flexibility I like to make my functions work on summarized as well as non-summarized objects.

Copy link
Collaborator

@alexpghayes alexpghayes left a comment

Choose a reason for hiding this comment

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

Sounds good, I'm on board. Let's just make sure that the information in your comment above makes it into the documentation!

R/emmeans-tidiers.R Outdated Show resolved Hide resolved
R/emmeans-tidiers.R Show resolved Hide resolved
tests/testthat/test-emmeans.R Outdated Show resolved Hide resolved
crsh and others added 2 commits Aug 14, 2019
Co-Authored-By: alex hayes <alexpghayes@gmail.com>
- Adds joint_tests()-example
- Removes strict = FALSE from tests
@crsh
Copy link
Contributor Author

crsh commented Aug 14, 2019

Thanks for the comments. I just pushed a commit that makes the requested changes.

@alexpghayes
Copy link
Collaborator

Can you merge in recent updates from the master branch? (Let me know if you'd like git advice!)

@crsh
Copy link
Contributor Author

crsh commented Aug 15, 2019

Of course! There should be no more merge conflicts now.

@lintr-bot

This comment has been minimized.

@alexpghayes alexpghayes merged commit beab4ef into tidymodels:master Aug 15, 2019
@alexpghayes
Copy link
Collaborator

Wonderful, thank you! Does this close #692?

@crsh
Copy link
Contributor Author

crsh commented Aug 15, 2019

I'm afraid, closing that issue will be a little more work and another PR. I've started on it but it'll be a little longer.

alexpghayes added a commit that referenced this pull request Apr 23, 2020
* Adds tidy-method form summary_emm-objects.

* Updates NEWS

* Apply suggestions from code review

Co-Authored-By: alex hayes <alexpghayes@gmail.com>

* Makes requested changes for emmeans tidiers. (#691)

- Adds joint_tests()-example
- Removes strict = FALSE from tests

* Roxygenizes documentation.

* Improves consistency of post-hoc comparison tidies (i.e. glht, stats::TukeyHSD, and emmeans). See #692

* Fixes failing tests and roxygenizes.

* Adds NEWS entry.

* Fixes more failing tests.

* Fix bug in emmeans and multcomp examples.

* Implement revision suggested by @alexpghayes

Co-Authored-By: alex hayes <alexpghayes@gmail.com>

Co-authored-by: alex hayes <alexpghayes@gmail.com>
@github-actions
Copy link

github-actions bot commented Mar 6, 2021

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants