You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently spread does not work on grouped_df objects. Toy example:
library(dplyr) # from github, 2014 Oct 31
library(tidyr) # from github, 2014 Oct 31## generate datahousehold<- rep(1:500, times= sample(5, 500, replace=TRUE))
df<-data.frame(household=household,
day= sample(3, length(household), replace=TRUE))
## count day indexes for each householddf_days<- summarize(group_by(df, household, day), day_count= n())
## spread, converting to data frame -- works
spread(as.data.frame(df_days), day, day_count)
## spread without conversion -- does not work
spread(df_days, day, day_count)
where the last line fails with
Error in `[.grouped_df`(data, key_col) :
cannot group, grouping variables 'household' not included
Maybe I misunderstood something, but I thought grouped_df could be used like data frame.
The text was updated successfully, but these errors were encountered:
Apparently
spread
does not work ongrouped_df
objects. Toy example:where the last line fails with
Maybe I misunderstood something, but I thought
grouped_df
could be used like data frame.The text was updated successfully, but these errors were encountered: