Category
이라는 GROUPED BY 값의 두 세트를 전달할 수 있기를 원합니다. 패키지 plyr
에서 ddply
을 사용하여이 작업을 수행 할 수있는 방법이 있습니까?열을 기반으로 값을 ddply로 전달할 수 있습니까?
ddply(idata.frame(data), .(Category), wilcox.test, data[Type=="PRE",], data[Type=="POST",])
wilcox.test
는 다음과 같은 기능입니다 :
나는 이런 식으로 뭔가하고 싶은
Description
Performs one- and two-sample Wilcoxon tests on vectors of data; the latter is also known as ‘Mann-Whitney’ test.
Usage
wilcox.test(x, ...)
Arguments
x
numeric vector of data values. Non-finite (e.g. infinite or missing) values will be omitted.
y
an optional numeric vector of data values: as with x non-finite values will be omitted.
.... rest of the arguments snipped ....
을 내가 가지고 dput
에서 다음과 같은 출력 :
structure(list(Category = c("A", "C",
"B", "C", "D", "E",
"C", "A", "F", "B",
"E", "C", "C", "A",
"C", "A", "B", "H",
"I", "A"), Type = c("POST", "POST",
"POST", "POST", "PRE", "POST", "POST", "PRE", "POST",
"POST", "POST", "POST", "POST", "PRE", "PRE", "POST",
"POST", "POST", "POST", "POST"), Value = c(1560638113,
1283621, 561329742, 2727503, 938032, 4233577690, 0, 4209749646,
111467236, 174667894, 1071501854, 720499, 2195611, 1117814707,
1181525, 1493315101, 253416809, 327012982, 538595522, 3023339026
)), .Names = c("Category", "Type", "Value"), row.names = c(21406L,
123351L, 59875L, 45186L, 126720L, 94153L, 48067L, 159371L, 54303L,
63318L, 104100L, 58162L, 41945L, 159794L, 57757L, 178622L, 83812L,
130655L, 30860L, 24513L), class = "data.frame")
어떤 제안이?
ddply(idata.frame(data), .(Category),
function(x) wilcox.test(x[Type == "PRE",], x[Type == "POST",])
난 당신이 자신에게 조금 조정할해야합니다 있도록 wilcox.test
기능이 기본적으로 data.frame
에 연결하는 뭔가 좋은 반환 확실하지 않다 :
+1 위대한 설명에 감사드립니다. :) – Legend