I have the following data
Name Date Message
Ted Foe 2011-06-10T05:06:30+0000 I love this product
Sin
Grouped by the 'Date' column after converting to Date
class, we get the number of rows (n()
) with summarise
. If we need the 'Date' elements that are missing in the original dataset, create a new dataset with the sequence of minimum to maximum 'Date' and do a left_join
df1 <- df %>%
group_by(Date = as.Date(Date)) %>%
summarise(comments = n())
expand.grid(Date = seq(min(df1$Date), max(df1$Date), by = '1 day')) %>%
left_join(., df1)