I've begun to gradually shift to R from Excel but I'm still having some difficulties with (relatively simple) calculations.
I want to create a frequency version of my variable x, let's call it "xfrequency".
Please, see the sample of my data below.
The desired variable xfrequency should basically count the number of x's, during a certain period (country-year). In the sample data the observation period is from 1990 to 1995. So, in 1994 Canada recieved 4 x's in total.
Perhaps there is a relevant function for this out there? Thanks!
country year x xfrequency
CAN 1990 1 1
CAN 1991 0 0
CAN 1992 1 2
CAN 1993 0 0
CAN 1994 2 4
CAN 1995 1 5
USA 1990 0 0
USA 1991 2 2
USA 1992 1 3
USA 1993 0 0
USA 1994 1 4
USA 1995 0 0
GER 1990 NA NA
GER 1991 1 1
GER 1992 0 0
GER 1993 1 2
GER 1994 2 4
GER 1995 1 5