I have the following data
Name Date Message
Ted Foe 2011-06-10T05:06:30+0000 I love this product
Sina Fall 2011-06-10T05:07:33+0000 Not my type of product
Steve Hoe 2011-06-11T05:06:30+0000 Great Discussion! Thanks
Selda Dee 2011-06-13T05:12:30+0000 Seen elsewhere
Steven Hoe 2011-06-13T03:17:31+0000 Where?
Selda Dee 2011-06-13T05:17:56+0000 Tinder
I want to aggregate by days so that I end up with a time series like this
Date Number of Posts
2011-06-10 2
2011-06-11 1
2011-06-12 0
2011-06-13 3
I already tried the following
summary_df <- df %>% group_by(Date) %>% summarise(comments = count(message))
But this is not working. Any quick dplyr based solution would be great.
Thanks for the help!
Cheers, Raoul
Grouped by the 'Date' column after converting to
Date
class, we get the number of rows (n()
) withsummarise
. 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 aleft_join