add labels to lattice barchart

bar-chart, lattice, r

Solution

Create a custom panel function, e.g.

library("lattice")
p <- barchart((1:10)^2~1:10, horiz=FALSE, ylim=c(0,120),
              panel=function(...) { 
                args <- list(...)
                panel.text(args$x, args$y, args$y, pos=3, offset=1)
                panel.barchart(...)
              })
print(p)

Problem

I would like to place the value for each bar in barchart (lattice) at the top of each bar. However, I cannot find any option with which I can achieve this. I can only find options for the axis.

Original source