Skip to content
Prev 75943 / 398502 Next

plot(type="h") equivalent in Lattice?

On 8/19/05, Maciej Kalisiak <mkalisiak at gmail.com> wrote:
Yes, all (or most, at least) lattice functions will do that if the
variable is a factor or shingle (which barchart forces).
Your best bet is to coerce to numeric, and use xyplot, whose default
panel function honors type='h'. e.g.

xyplot(yield ~ as.numeric(variety) | site + year, 
       data = barley, type = 'h')

or for horizontal bars, 

xyplot(as.numeric(variety) ~ yield | site + year, 
       data = barley, type = 'h', horizontal = TRUE)

Had too many labels not been a problem, you could also have used

barchart(as.numeric(variety) ~ yield | site + year, 
         data = barley, panel = panel.xyplot, type = 'h')

Deepayan