Finding the mean of a subset

女生的网名这么多〃 提交于 2020-03-16 07:05:06

问题


I have made a subset from the dataframe 'Indometh' called 'indo':

indo
   Subject time conc
1        1 0.25 1.50
13       2 0.50 1.63
24       3 0.50 1.49
25       3 0.75 1.16
34       4 0.25 1.85
35       4 0.50 1.39
36       4 0.75 1.02
46       5 0.50 1.04
57       6 0.50 1.44
58       6 0.75 1.03

I want to find what the average concentration for the subset is. I have used code but to no avail:

mean(subset(indo, conc >1 & conc <2))

I know summary(indo) will show the mean of the concentration but wanted to know if there was another way I could do this just for conc.


回答1:


You can try subsetting via bracket notation:

mean(indo$conc[indo$conc > 1 & indo$conc < 2])


来源:https://stackoverflow.com/questions/47746116/finding-the-mean-of-a-subset

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!