I have a data frame where one column is species\' names, and the second column is abundance values. Due to the sampling procedure, some species appear more than once (i.e.,
> tapply(df$y, df$x, sum) sp1 sp2 sp3 sp4 2 9 7 3
if it has to be a data.frame Ben's answer works great. or you can coerce the tapply output.
data.frame
out <- tapply(df$y, df$x, sum) > data.frame(x=names(out), y=out, row.names=NULL) x y 1 sp1 2 2 sp2 9 3 sp3 7 4 sp4 3