向R中的箱线图添加统计信息表 [英] Adding a table of statistics to a boxplot in R

查看:95
本文介绍了向R中的箱线图添加统计信息表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一个图形上创建了两个箱形图,如下所示。

I have created two boxplots on the same graph, as per code below

a = c(1,1,1,2,2,2,2,2,5,5,5,5,5,6,5,4,7)

b = c(1,1,2,2,2,2,2,2,5,5,5,5,5,6,5,3,8)

boxplot(  a
        , b
        , names = c("Category a", "Category b")
        , staplewex = 1 
        , horizontal = TRUE ) 

我还要添加重要数据点,Q1中位数等,作为标签或类似于图例的图形汇总表-这样可能吗?

I would like to also add the important data points, Q1 median etc, as labels or as a summary table on the graph similar to a legend - is this possible?

谢谢

推荐答案

感谢您对plotrix软件包的帮助!

Thanks for your help the plotrix package works!

install.packages("plotrix")

library(plotrix)

table <- sapply(as.data.frame(cbind(a,b)),summary)

addtable2plot(22,2,table)

这篇关于向R中的箱线图添加统计信息表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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