I have a data set of comic book unit sales by volume (ex. Naruto v10) that I need to reduce to sales by series (so all Naruto volume unit sales would be added together into a single observation). I have a variable "series" that identifies the series of each observation. The equivalent code in Stata would be:
by series, sort:replace unitssales=sum(unitssales); by series, sort:keep if _n==_N
But I'm trying to figure out how to do this in R. Any help would be much appreciated! Thanks in advance!