如果行中的每个值都大于不同数据框中的相应行,我想对数据进行子集化。我还需要跳过一些顶行。这些以前的问题对我没有帮助,但它是相关的:
> A
name1 name2
cond trt ctrl
hour 0 3
A 1 1
B 10 1
C 1 1
D 1 1
E 10 10
> B
name1 name2
cond trt ctrl
hour 0 3
A 1 1
B 1 10
C 1 1
D 1 1
E 1 1
我要这个。只有 A 中的所有值都大于 B 的行:
name1 name2
cond trt ctrl
hour 0 3
E 10 10
我试过这 3 行:
subset(A, TRUE, select=(A[3:7,] > B[3:7,]))
subset(A, A > B)
A[A[3:7,] > B[3:7,]]
非常感谢。下面是生成数据的代码:
A <- structure(list(name1 = c("trt", "0", "1", "10", "1", "1", "10"
), name2 = c("ctrl", "3", "1", "1", "1", "1", "10")), .Names = c("name1",
"name2"), row.names = c("cond", "hour", "A", "B", "C", "D", "E"
), class = "data.frame")
B <- structure(list(name1 = c("trt", "0", "1", "1", "1", "1", "1"),
name2 = c("ctrl", "3", "1", "10", "1", "1", "1")), .Names = c("name1",
"name2"), row.names = c("cond", "hour", "A", "B", "C", "D", "E"
), class = "data.frame")
############# 2/28/13 提出后续问题