求子集的均值 [英] Finding the mean of a subset

查看:61
本文介绍了求子集的均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从数据帧"Indometh"中创建了一个子集,称为"indo":

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))

我知道summary(indo)将显示浓度的平均值,但想知道是否还有另一种方法可以使浓度保持一致.

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.

推荐答案

您可以尝试通过方括号表示法进行子设置:

You can try subsetting via bracket notation:

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

这篇关于求子集的均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆