简体   繁体   English

match.arg(p.adjust.method)中的错误:“ arg”必须为NULL或字符向量

[英]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 ). 为了将其与摘要统计信息结合起来,您需要确定要加入的组( group1group2 )。 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 ,因此meansdmedian指的是group1 ,而p.value指的是group1group2之间的差异。

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.

相关问题 match.arg(regions) 中的错误:“arg”必须为 NULL 或字符向量 - Error in match.arg(regions) : 'arg' must be NULL or a character vector 警告:match.arg中的错误:&#39;arg&#39;必须为NULL或字符向量 - Warning: Error in match.arg: 'arg' must be NULL or a character vector Shiny 应用程序中的“match.arg(position) 错误:‘arg’必须为 NULL 或字符向量” - "Error in match.arg(position) : 'arg' must be NULL or a character vector" in Shiny app match.arg(position) 中的闪亮错误:“arg”必须为 NULL 或字符向量 - shiny Error in match.arg(position) : 'arg' must be NULL or a character vector match.arg(opt_crit)中的错误:“ arg”必须为NULL或字符向量 - Error in match.arg(opt_crit) : 'arg' must be NULL or a character vector 运行应用程序时出现闪亮错误:match.arg(position) 中的错误:&#39;arg&#39; 必须为 NULL 或字符向量 - Shiny Error when running App: Error in match.arg(position) : 'arg' must be NULL or a character vector 尝试运行以下代码中的插补函数时,“match.arg(what) 中的错误:&#39;arg&#39; 必须为 NULL 或字符向量” - "Error in match.arg(what) : 'arg' must be NULL or a character vector" when trying to run the impute function in the below code match.arg(mvnTest)中的错误:“ arg”的长度必须为1 - Error in match.arg(mvnTest) : 'arg' must be of length 1 &#39;arg&#39;必须为NULL或字符向量 - 'arg' must be NULL or a character vector Rigraph degree()&#39;match.arg中的错误&#39; - R igraph degree() 'Error in match.arg'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM