如何在 R 中给定 table 的每一行生成箱线图?
How to Generate boxplot for everyrow in the give table in R?
我在文本文件中有以下格式的数据:
#Position Mean Median Lower_Quartile Upper_Quartile 10th_Percentile 90th_Percentile
1 33.79097948291701 34.0 34.0 34.0 34.0 34.0
2 33.79898508246205 34.0 34.0 34.0 34.0 34.0
3 33.81967715123146 34.0 34.0 34.0 34.0 34.0
4 33.821820727065926 34.0 34.0 34.0 34.0 34.0
5 33.82225819152194 34.0 34.0 34.0 34.0 34.0
6 37.62032459862636 38.0 38.0 38.0 38.0 38.0
7 37.61853099435671 38.0 38.0 38.0 38.0 38.0
8 37.574522070081805 38.0 38.0 38.0 38.0 38.0
9 37.54608688044097 38.0 38.0 38.0 37.0 38.0
每一行用于生成箱线图。我想生成一个图表,显示一张图表中 table 以上所有行的箱线图,按位置排序。默认的箱线图选项将每一列加载到箱线图中。如何更改?
我最初的方法是使用默认的箱线图命令,为每一列生成箱线图。
鉴于 df
包含您的数据,您可以尝试
library(ggplot2)
ggplot(df, aes(as.factor(Position))) +
geom_boxplot(aes(ymin = X10th_Percentile, lower = Lower_Quartile, middle = Median, upper = Upper_Quartile, ymax =X90th_Percentile), stat = "identity")
我在文本文件中有以下格式的数据:
#Position Mean Median Lower_Quartile Upper_Quartile 10th_Percentile 90th_Percentile
1 33.79097948291701 34.0 34.0 34.0 34.0 34.0
2 33.79898508246205 34.0 34.0 34.0 34.0 34.0
3 33.81967715123146 34.0 34.0 34.0 34.0 34.0
4 33.821820727065926 34.0 34.0 34.0 34.0 34.0
5 33.82225819152194 34.0 34.0 34.0 34.0 34.0
6 37.62032459862636 38.0 38.0 38.0 38.0 38.0
7 37.61853099435671 38.0 38.0 38.0 38.0 38.0
8 37.574522070081805 38.0 38.0 38.0 38.0 38.0
9 37.54608688044097 38.0 38.0 38.0 37.0 38.0
每一行用于生成箱线图。我想生成一个图表,显示一张图表中 table 以上所有行的箱线图,按位置排序。默认的箱线图选项将每一列加载到箱线图中。如何更改?
我最初的方法是使用默认的箱线图命令,为每一列生成箱线图。
鉴于 df
包含您的数据,您可以尝试
library(ggplot2)
ggplot(df, aes(as.factor(Position))) +
geom_boxplot(aes(ymin = X10th_Percentile, lower = Lower_Quartile, middle = Median, upper = Upper_Quartile, ymax =X90th_Percentile), stat = "identity")