我有一个大数据框。这是样本数据(前几个观察)。
Year ComplaintCategory Days Loop
FY07-09 Service 1 Short
FY07-09 Service 22 Short
FY07-09 Product 15 Long
FY07-09 Product 6 Long
FY07-09 Product 6 Long
FY07-09 Service 3 Short
我只想在条件箱线图上显示中值。计算对应于每个箱线图的中值并将其存储在向量CalculatedMedian中。中值如下所示。
12.0 26.0 13.5 17.0 20.0 48.0 35.0 21.0 NA NA 0.0 NA NA 29.0 30.0 19.0
如何仅打印每个面板中的中值以及中值位置的相应箱线图?
bwplot(Days ~ Loop | factor(Year),
ProductData, layout = c(8, 1), pch = rep("|", 2),
ylim = c(-10,100), scales=list(y = list(at=seq(0, 100,10))),
main=list(label="", cex=1.4),
ylab=list(label="Settlement Days", cex=1.3),
xlab=list(label="Loop", cex=1.3),
par.settings = list( box.rectangle = list(col= "black",lwd=1.3,lty=1),
box.umbrella = list(col= "black",lwd=1.3,lty=1),
ylim = seq(0, 100, by=10),
plot.symbol = list(col='black')),
panel=function(x, y,...) {
panel.abline(v = x, h = seq(0, 100, by = 10),
col = "lightgrey",lty = 2,lwd=1)
panel.bwplot(x, y,fill=c('lemonchiffon1','lavenderblush1'),...)
panel.text(x = x, y =CalculatedMedian, labels = CalculatedMedian)}
下面是代码的输出: