R语言:wilcox_test 出现报错 Can't extract columns that don't exist. x Column doesn't exist.

运行以下命令时:

stat.test <- all %>% 
    wilcox_test(colnames(all)[1] ~ colnames(all)[2]) %>%
    adjust_pvalue(method ="BH") %>% 
    add_significance("p.adj")
stat.test 

出现报错:

Error in vec_as_location2_result():
! Can't extract columns that don't exist.
x Column colnames(all)[1] doesn't exist.

解决方案:

stat.test <- all %>% 
    wilcox_test(as.formula(paste(colnames(all)[1], colnames(all)[2], sep = "~"))) %>%
    adjust_pvalue(method ="BH") %>% 
    add_significance("p.adj")
stat.test 
posted @ 2023-02-21 14:29  橙子牛奶糖  阅读(210)  评论(0编辑  收藏  举报