match.arg(p.adjust.method)中的错误:"arg"必须为NULL或字符向量 [英] Error in match.arg(p.adjust.method) : 'arg' must be NULL or a character vector

查看:106
本文介绍了match.arg(p.adjust.method)中的错误:"arg"必须为NULL或字符向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的数据

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))

我想加入两个表.id是标识符.

I want to join two tables. id is identificator.

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")

并得到错误

Error in match.arg(p.adjust.method) : 
  'arg' must be NULL or a character vector

该脚本分别为每个标识符执行的操作方法IE.所需的输出

How to do that this script performed for each indentificator separately I.E. Desired output

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

推荐答案

可以使用 group_by do 固定第一部分,如下所示.

The first part can be fixed using group_by and do as follows.

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

为了将其与摘要统计信息结合起来,您需要确定要加入哪个组( group1 group2 ).在下文中,我加入了 group1 ,因此 mean sd median 指的是 group1 p.value 是指 group1 group2 之间的区别.

In order to combine this with the summary statistics, you need to decide which group you want to join with (group1 or 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.

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'))

这篇关于match.arg(p.adjust.method)中的错误:"arg"必须为NULL或字符向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆