Conditional table sum on r -


this question has answer here:

what i'm trying sum table variable if 1 true, example:

this part of table:

  school  sex  age  studytime 1 2       m    18   2,1 1 1       m    19   2,8 1 2       f    18   2,6 1 3       m    17   2,7 1 3       f    17   1,1 1 4       f    19   3,8 1 1       m    20   2,5 

and need sum studytime each sex, this:

sex  studytime m    10,1 f    7,5 

a base r method based on aggregate below:

aggregate(x$studytime,by=list(sex=x$sex),sum) 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -