I have the following data table :
structure(list(Date = c("2015-04-01", "2015-04-01", "2015-04-01",
"2015-04-01", "2015-04-01", "2015-04-01"), Category = structure(c(4L,
4L, 4L, 5L, 5L, 6L), .Label = c("Bakery ", "Branded goods", "Breakfast ",
"Canned/Packaged ", "Cooking essentials ", "Household ", "NO CATEGORY",
"Personal care", "Stationary ", "Vehicle accessories"), class = "factor"),
Sub_Category = c("carbonated drink ", "carbonated drink ",
"carbonated drink ", "Dairy ", "Dairy ", "Stationary "),
Product = c("soft drink", "soft drink", "soft drink", "Butter ",
"Butter ", "A4 paper"), Brand = c("7 up ", "7 up ", "7 up ",
"Amul", "Amul", "NO BRAND"), Day = c(1L, 1L, 1L, 1L, 1L,
1L), Month = c(4L, 4L, 4L, 4L, 4L, 4L), Year = c(2015L, 2015L,
2015L, 2015L, 2015L, 2015L), MRP = c("55", "25", "70", "37",
"37", "0.5"), Quantity = c(1, 1, 1, 1, 1, 20), Sales = c(55,
25, 70, 37, 37, 10), Wday = c("Wednesday", "Wednesday", "Wednesday",
"Wednesday", "Wednesday", "Wednesday"), Week = c(13L, 13L,
13L, 13L, 13L, 13L), X = c(NA, NA, NA, NA, NA, NA), X. = c(NA,
NA, NA, NA, NA, NA)), .Names = c("Date", "Category", "Sub_Category",
"Product", "Brand", "Day", "Month", "Year", "MRP", "Quantity",
"Sales", "Wday", "Week", "X", "X."), sorted = "Date", class = c("data.table",
"data.frame"), row.names = c(NA, -6L), .internal.selfref = <pointer: 0x00000000001b0788>)
and I wish to show the sum of(Quantity) or sum(sales) for each type of category for each day spanning the entire date column.
I have tried :
data2 <- data %>% group_by(data$Date) %>% summarise_each(funs(sum))
but i get:
Error in is_list(x) : object 'rlang_is_list' not found
Also tried :
aggregate(cbind(data$Category,data$Sales,data$Quantity)~data$Date,
data=data,FUN=sum)
this produces an entirely different output. ;/
Is there a way to get this done ?
Even after uninstalling rlang,dplyr and ggplot2 package, the error still remains. Is there a way around this ?
Thanks in advance