I have a data frame obtained using the following sequence of pipe operations:
library(dplyr)
data_agg = data %>%
group_by(Year,Month) %>%
summarise( monthly_users = sum(Users))
head(data_agg)
looks like this:
Year Month monthly_users
1 2013 07 22
2 2013 08 221
3 2013 09 252
4 2013 10 313
5 2013 11 322
6 2013 12 339
I now dput()
it, obtaining:
structure(list(Year = c("2013", "2013", "2013", "2013", "2013",
"2013", "2014", "2014", "2014", "2014", "2014", "2014", "2014"
), Month = c("07", "08", "09", "10", "11", "12", "01", "02",
"03", "04", "05", "06", "07"), monthly_users = c(22L, 221L, 252L,
313L, 322L, 339L, 344L, 338L, 301L, 307L, 401L, 383L, 318L)), .Names = c("Year",
"Month", "monthly_users"), row.names = c(NA, -13L), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), vars = list(Year), drop = TRUE)
However, when I run the above output from dput()
I get the following error:
Error in structure(list(Year = c("2013", "2013", "2013", "2013", "2013", :
object 'Year' not found
Why is this happening?
See Question&Answers more detail:os