[英]Finding corresponding values from already subsetted vectors in R?
Background: I have my dataset as a csv file called D
( please load it to your R ): 背景:我将数据集保存为名为
D
的csv文件( 请加载到R ):
D = read.csv("https://docs.google.com/uc?id=0B5V8AyEFBTmXWU40TUZGTURQWlU&export=download")
I use the following function to obtain 2 quantities from my data ( please source to your R ): 我使用以下函数从我的数据中获取2个数量 ( 请提供给您的R ):
source("https://docs.google.com/uc?id=0B5V8AyEFBTmXWTk0LWhaMkY2b3M&export=download")
The 2 quantities are obtained as follows: 这两个数量的获得如下:
b = BF.d.pvalue(t = D$t.value, n1 = D$n1, n2 = D$n2)
BF = b[1, ] ; p.value = b[2, ]
Subsetting Details: I have subsetted p.value
larger than .05
and their corresponding BF
s: 子集详细信息:我已将大于
.05
p.value
及其相应的BF
s进行了子集化:
pvalue.05_1 = p.value[p.value > .05] ;
BF.pvalue.05_1 = BF[p.value > .05]`
I have further subsetted BF.pvalue.05_1
that are between 1/10
and 1/3
: 我进一步
BF.pvalue.05_1
,它们在1/10
和1/3
之间:
BF.pvalue.05_1_.1_.33 = BF.pvalue.05_1[BF.pvalue.05_1 > 1/10 & BF.pvalue.05_1 <= 1/3]
Question: Now I'm wondering how I can find the corresponding p.value
for BF.pvalue.05_1_.1_.33
above? 问:现在我想知道怎样才能找到相应的
p.value
为BF.pvalue.05_1_.1_.33
以上?
The preferred way to do this is to combine your data to a dataframe
and then using the subset
command for filtering. 执行此操作的首选方法是将数据合并到
dataframe
,然后使用subset
命令进行过滤。
myDf = data.frame(p = p.value, BF = BF)
head(myDf)
# p BF
# 1 2.274873e-06 6.241835e+03
# 2 3.811612e-02 1.736017e+00
# 3 0.000000e+00 2.592434e+147
# 4 0.000000e+00 1.982820e+130
# 5 0.000000e+00 1.315152e+29
# 6 9.992007e-15 4.442134e+11
Now, whenever you subset your data rowwise , you will have access to both the p
value and the BF
value. 现在,无论何时按行对数据进行子集设置 ,您都可以访问
p
值和BF
值。
firstSubset = subset(myDf, p > .05)
dim(firstSubset)
# [1] 175 2
secondSubset = subset(firstSubset, BF > .1 & BF < 1/3)
dim(secondSubset)
# [1] 76 2
head(secondSubset)
# p BF
# 28 0.8518770 0.3131790
# 34 0.9358011 0.2910234
# 35 0.9302671 0.2911639
# 52 0.6825720 0.3101911
# 88 0.7201547 0.2770751
# 96 0.6472360 0.2868055
Alternatively, you can use both conditions simultaniousely 或者,您可以同时使用两个条件
secondSubset = subset(myDf, (BF > .1) & (BF < 1/3) & (p > .05))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.