Assuming this data:
df <- tibble(
word = c("apple", "apple","banana", "pear","pear","A","A","A"),
i = seq_along(word),year=c(2000,2001,2000,2000,2001,2000,2001,2002)
)
I want to calculate the mean of column i for all words (per year) in column word without A and banana. and give the name out the output would be
word i year
<chr> <int> <dbl>
1 out 2.5 2000
2 out 3.5 2001
3 banana 4 2000
5 A 7 2000
8 A 8 2001
9 A 9 2002