I have a data frame with 4 columns titled 'year' 'name' 'sex' 'amount'. Here is a sample data set
set.seed(1)
data = data.frame(year=sample(1950:2000, 50, replace=TRUE),name=sample(LETTERS, 50, replace=TRUE),
sex=sample(c("M", "F"), 50, replace=TRUE), amount=sample(40:100, 50, replace=TRUE))
I want to find only names that occur as both an ‘m’ and an ‘f’ and sum the amount for each year.
Any help would be greatly appreciated