美文网首页
【R语言】箱线图统计检验线段长度

【R语言】箱线图统计检验线段长度

作者: 研究僧小蓝哥 | 来源:发表于2020-08-31 14:19 被阅读0次
    rm(list = ls())
    
    data("iris")
    
    library(ggplot2)
    library(ggsignif)
    library(ggsci)
    
    comp_list = list(c('setosa','versicolor'),
                     c('setosa','virginica')) 
    
    ggplot(iris, aes(Species, Sepal.Length, color = Species)) +
            geom_boxplot(width = 0.6) +
            geom_point(size = 1, alpha = 0.5) +
            geom_signif(comparisons = comp_list,
                        test = 'wilcox.test',
                        step_increase = 0.1,
                        map_signif_level = TRUE,
                        vjust = 0.5) +
            scale_x_discrete(limit = c('versicolor','setosa','virginica')) +
            scale_color_aaas() +
            theme_bw()+
            theme(legend.position = 'none')
    
    ggplot(iris, aes(Species, Sepal.Length, color = Species)) +
            geom_boxplot(width = 0.6) +
            geom_point(size = 1, alpha = 0.5) +
            geom_signif(comparisons = comp_list,
                        test = 'wilcox.test',
                        step_increase = 0.1,
                        map_signif_level = TRUE,
                        vjust = 0.5,
                        y_position = c(8,8.5),
                        tip_length = c(0.1,0.25,
                                       0.7,0.1),
                        linetype = 'dashed',
                        color = 'black') +
            scale_x_discrete(limit = c('versicolor','setosa','virginica')) +
            scale_color_aaas() +
            theme_bw()+
            theme(legend.position = 'none')
    

    相关文章

      网友评论

          本文标题:【R语言】箱线图统计检验线段长度

          本文链接:https://www.haomeiwen.com/subject/nyaysktx.html