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

Take advantage of matrix column support #1126

Merged
merged 6 commits into from Nov 8, 2022

Conversation

capnrefsmmat
Copy link
Contributor

@capnrefsmmat capnrefsmmat commented Nov 6, 2022

I noticed the documentation for augment.lm() claimed that matrix columns are not supported and hence poly() won't work, but I noticed this while augmenting a model with a poly() term that worked just fine. It turns out matrix column support was added in tibble 1.0.0, so matrix columns will work fine. I've updated the augment template documentation accordingly.

Examining the NEWS for broom 0.5.0, I saw this also meant augment.survreg() and augment.coxph() required an explicit data argument, because their model.frame() would include matrix columns. I verified that using model.frame() works just fine now. This should not be a breaking change, because anyone who left the data argument blank before would have gotten an error, whereas now they will get a meaningful result.

I have not committed the updated Rd files, because I don't have all the zillion packages supported by broom installed. But I have verified that the survival tests still pass. You're welcome to rebuild the Rd on this branch.

I'll commit a NEWS update for the augment.survreg() and augment.coxph() shortly. I'm already in the DESCRIPTION from #1112.

When the augment() documentation was first written, evidently matrix
columns were not allowed in tibbles. But they have been supported since
tibble version 1.0.0: tidyverse/dplyr#3630

For instance, augment.lm() works correctly for a model containing poly()
or ns() terms, placing those terms in matrix columns as expected.
This was forbidden in broom 0.5.0 because tibbles did not support matrix
columns, and Surv() produces matrix columns in the model.frame(). But
since tibble 1.0.0, matrix columns are supported, and these work fine
with the default model.frame().
@capnrefsmmat
Copy link
Contributor Author

The first CHECK failure appears to be because I didn't rebuild the Rd files, as I mentioned, not because of a test failure.

@simonpcouch
Copy link
Collaborator

Great, thank you @capnrefsmmat! Just pushed those doc updates.

@simonpcouch simonpcouch merged commit 050fcd4 into tidymodels:main Nov 8, 2022
@github-actions
Copy link

This pull request has been automatically locked. If you believe the issue addressed here persists, please file a new PR (with a reprex: https://reprex.tidyverse.org) and link to this one.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2022
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

2 participants