[英]Error in match.arg(p.adjust.method) : 'arg' must be NULL or a character vector
Here my data 这是我的数据
mydat=structure(list(id = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), group = c(1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L), var = c(23L, 24L, 24L, 23L, 23L,
24L, 24L, 23L, 23L, 24L, 24L, 23L, 23L, 24L, 24L, 23L, 23L, 24L,
24L, 23L, 23L, 24L, 24L, 23L)), .Names = c("id", "group", "var"
), class = "data.frame", row.names = c(NA, -24L))
I want to join two tables. 我想加入两个表。 id is identificator. id是标识符。
library(tidyverse)
mdyat %>%
with(.,pairwise.wilcox.test(var,id, group, exact =F)) %>%
broom::tidy() %>%
complete(id,group) %>%
left_join(mydat %>%
group_by(id,group)) %>%
summarise_all(c("mean", "sd", "median"))
by=c("id,group")
and get the error 并得到错误
Error in match.arg(p.adjust.method) :
'arg' must be NULL or a character vector
How to do that this script performed for each indentificator separately IE Desired output 该脚本如何为每个标识符分别执行IE所需的输出
id mean sd median p.value
1 1 23,5 0.5773503 23,5 NA
1 2 23,5 0.5773503 23,5 1
1 3 23,5 0.5773503 23,5 1
2 1 23,5 0.5773503 23,5 NA
2 2 23,5 0.5773503 23,5 1
2 3 23,5 0.5773503 23,5 1
Your function arguments are wrong: 您的函数参数错误:
pairwise.wilcox.test(var,id, group, exact =F)
?pairwise.wilcox.test
states the correct syntax as: ?pairwise.wilcox.test
将正确的语法声明为:
pairwise.wilcox.test(x, g, p.adjust.method = p.adjust.methods,
paired = FALSE, ...)
which means the third function argument should be p.adjust.method
, not group
. 这意味着第三个函数参数应该是p.adjust.method
,而不是group
。
The first part can be fixed using group_by
and do
as follows. 可以使用group_by
固定第一部分,并do
以下操作。
mydat %>%
group_by(id) %>%
do({
with(., pairwise.wilcox.test(var, group, exact =F)) %>% broom::tidy()
})
## # A tibble: 6 x 4
## # Groups: id [2]
## id group1 group2 p.value
## <int> <fctr> <chr> <dbl>
## 1 1 2 1 1
## 2 1 3 1 1
## 3 1 3 2 1
## 4 2 2 1 1
## 5 2 3 1 1
## 6 2 3 2 1
In order to combine this with the summary statistics, you need to decide which group you want to join with ( group1
or group2
). 为了将其与摘要统计信息结合起来,您需要确定要加入的组( group1
或group2
)。 In the following I joined with group1
, so the mean
, sd
and median
refer to group1
and the p.value
refers to the difference between group1
and group2
. 在下文中,我加入了group1
,因此mean
, sd
和median
指的是group1
,而p.value
指的是group1
和group2
之间的差异。
mydat %>%
group_by(id) %>%
do({
with(., pairwise.wilcox.test(var, group, exact =F)) %>% broom::tidy()
}) %>%
mutate(group1 = as.numeric(as.character(group1)),
group2 = as.numeric(as.character(group2))) %>%
complete(group1 = mydat$group) %>%
left_join(mydat %>% group_by(id,group) %>% summarise_all(c("mean", "sd", "median")),
by=c('id', 'group1'='group'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.