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

dplyr::group_by doesn't return fhx objects #137

Closed
brews opened this issue Jul 24, 2019 · 1 comment
Closed

dplyr::group_by doesn't return fhx objects #137

brews opened this issue Jul 24, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request invalid This doesn't seem right

Comments

@brews
Copy link
Member

brews commented Jul 24, 2019

dplyr::group_by doesn't return fhx objects. This means that users can't use burnr functions after dividing an fhx object by -- for example -- "series", because most of our burnr function explicitly check that input is an fhx object.

We should write a generic method for group_by so that it returns an fhx/tibble/whatever and our burnr functions accept its input.

Might also think of writing as_fhx() and as.fhx() functions to help users easily translate tibbles and data frames to fhx objects (see #120 ).

@brews brews added the enhancement New feature or request label Jul 24, 2019
@brews brews added this to the v0.5.0 milestone Jul 24, 2019
@brews brews self-assigned this Jul 24, 2019
@brews
Copy link
Member Author

brews commented Jul 24, 2019

As a quick fix can use the newly added as.fhx() in tidyr pipelines that use group_by().

For example, here is a (roundabout) tidyr way to get the first-year of each series in the lgr2 example data:

library(burnr)
library(tidyr)
data(lgr2)

lgr2 %>% 
  group_by(series) %>% 
  summarise(fy = summary(as.fhx(.data))$first_year)

So, we convert the grouped data back to an fhx with as.fhx(.data) and then run it through our burnr functions.

@brews brews added the invalid This doesn't seem right label Jul 25, 2019
@brews brews closed this as completed Jul 25, 2019
@brews brews removed this from the v0.5.0 milestone Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant