Closed koseri closed 8 years ago
The whole point of tbl_dt()
is to make a tbl_df
as opposed to a grouped_df
. Otherwise how would you coerce when needed?
Confused. Shouldn't that be "...whole point of tbl_df
..."?
Now I see that tbl_df
ungroups tbl_dfs, too:
identical ( (foo %>% tbl_df() %>% group_by(code) %>% ungroup() ), (foo %>% tbl_df() %>% group_by(code) %>% tbl_df() ) )
returns TRUE
My goal is to be able to convert back and forth between a tbl_df
and a tbl_dt
while preserving grouping information. Is there a different idiom for preserving groups than this:
preserved_groups <- groups(xdt)
xdf <- xdt %>% tbl_df() %>% group_by_ ( .dots = preserved_groups)
Creating a tbl_dt from a grouped tbl_df silently ungroups the result. Similarly, creating a tbl_df from a grouped tbl_dt silently ungroups the result. This behavior seems odd given the general tendency not to ungroup; I would have expected the group information to stay.