Hi all,
I have a list of names and dates. I want to group the entries by Name and count the number of Names for 'after 2016' and 'before 2016'. The count should be added to a new column.
I understand that I could use 'melt' to do that. But I am not quite sure how to do so. Since I also need to add additional conditions.
My input:
Name Date
Marc 2006
Carl 2003
Carl 2002
Carl 1990
Marc 1999
Max 2016
Max 2014
Marc 2006
Carl 2003
Carl 2002
Carl 2019
Marc 1999
Max 2016
Max 2014
My Output:
Before
2016 Countall CountWithCondition
Marc 1 4 2
Marc 0 0 0
Carl 1 5 4
Carl 0 1 1
Max 1 2 0
Max 0 2 1
It would be nice, if someone could point me in the right direction.
Thanks!
So the Output should have 2 entries for each Name, one with a count of Names before 2016 and one after. Addtionally a column which just stats 1 for before 2016 and 0 for after. As well as maybe a second column with count, but with an aditional condition.