且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用ggplot2的表格Boxplot

更新时间:2023-11-26 23:45:34

ggplot2 需要特定格式的数据。在这里,你需要 x = y = 其中 y 将是值, x 将是相应的列ID。使用 melt reshape2 包到 melt 获取数据这个格式的数据,然后绘图。

ggplot2 requires data in a specific format. Here, you need x= and y= where y will be the values and x will be the corresponding column ids. Use melt from reshape2 package to melt the data to get the data in this format and then plot.

require(reshape2)
ggplot(data = melt(dd), aes(x=variable, y=value)) + geom_boxplot(aes(fill=variable))