I'm trying to count the occurrences of false and true in a dataset to determine if an event is a comment to a post or a comment to a comment in a Facebook dataset.
I would like to do this in data.table
as I've noticed that this is often the fastest and most readable way to do this. The code below is code that I've tried, and it works. I would however like to do this operation in one line.
CEM_CtC <- aggregate_comments_data[event.is_comment_to_post =="false", .N, by = event.post.id]
CEM_CtP <- aggregate_comments_data[event.is_comment_to_post =="true", .N, by = event.post.id]
CEM_post_data <- merge(CEM_CtC, CEM_CtP, by = "event.post.id", all=T)
It is essential for the process that the outcome table is formatted like this
event.post.id CEM_CtC CEM_CtP
382719578 50 100
238947597 50 100
934829234 50 100