I am a beginner to R and I am stuck with a probably simple problem. I have a data frame NEI_small
like that:
Now I want to calculate the sum of the emissions per year. So It should look like that:
year Emission
1999 29920139
2002 41757550
How can I get the sum of a group ?
I tried this but it didn`t work :
sapply(split(NEI_small,NEI_small$year),sum(NEI_small$Emissions))
But I got this error :
Error in match.fun(FUN) : 'sum(NEI_small$Emissions)' ist nicht Funktion, Zeichen oder Symbol
Can anybody help me please?