R, Sum frequency data frame by name -


i have data.frame looks this:

      name         freq          1   species1        4               2   species2        8               3   species1        7               4   species1        10              5   species2        9               

i want sum frequency each species name. expected result:

      name             freq 1    species1           21 2    species2           17 

assuming attached data.frame, this

tapply(freq, index=list(name),fun=sum) 

or, data frame called "datax"

tapply(datax$freq, index=list(datax$name),fun=sum) 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -