我正在 R 中使用 box-percentile panel 函数绘制 box-percentile 图Hmisc
(panel.bpplot
) with bwplot
from lattice
.
我有一个数字向量(Length
),并希望显示其在因子变量各个水平上的分布(Month
).
这是一个带有虚假数据的示例:
例如,
set.seed(13)
Length<-sample(1:10, 1000, replace=TRUE)
Month<-sample(c("Apr","May","Jul","Aug","Sep","Nov"), 1000, replace=TRUE)
df<-cbind(Month, Length)
df<-as.data.frame(df)
df$Month<-factor(df$Month, levels=c("Apr","May","Jul","Aug","Sep","Nov"))
df$Length<-as.numeric(df$Length)
#plot horizontal box-percentile plot;
bwplot(Month~Length, data=df, panel=panel.bpplot)
这很好用。但我希望情节是vertical, with Month
在 x 轴上和Length
在 y 轴上。的文档panel.bpplot
说水平图使类别级别更加明显,但是,出于我的目的,我特别需要垂直图。有没有办法修改panel.bpplot
去做这个?