我希望能够传递两组按列分组的值Category
。有没有办法使用ddply
from package来做到这一点plyr
?
我想做这样的事情:
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")
有什么建议么?