select not working for grouped_df #170
Comments
Here is the implementation of
So the error comes from the Maybe we should lose the groupings or force selection of grouping variables. @hadley ? |
Ooh, I didn't think of that possibility. I think it would be best to give an error in this situation: e.g. "selection doesn't include grouping variables: vs". |
It seems to me Romain's proposal to implicitly select grouping variables was superior from a DRY or "war on boilerplate" point of view. Now we have to write
Mandated repetition of |
Yes, that's an excellent point. No reason to let people do something that they shouldn't want to do. |
Perhaps this should come with some sort of message letting the user know we've added variables to the selection. In any case, this can be handled in the |
I think it's reasonable to say that it's implicit in the grouping - i.e. a grouped select includes the grouping variables in the same way that a grouped arrange orders by the grouped variables. |
An alternative could be to remove the constraint and allow to drop grouping variables. This makes more sense than it seems: imagine you are doing resampling and you are only interested in the variation of an estimator, not exactly which group it comes from. But there are implications to this: I don't think it's natural to preserve the grouping when the grouping variables are gone. Hence it would become an implicit ungroup. |
Hi,
I think that select verb is not working as expected for grouped_df.
Here's a small reproductible example :
Using select
Using subset
The text was updated successfully, but these errors were encountered: