No reproducible example (see posting guide below) so minimal help. Remove the quotes from your formula. Why did you think they should be there? -- see ?formula.
Read the relevant portions of ?xyplot carefully (again?). You seemed to have missed: "*Primary variables:* The x and y variables should both be numeric in xyplot, and an attempt is made to coerce them if not. However, if either is a factor, the levels of that factor are used as axis labels. In the other four functions documented here, [ which includes barchart()] **exactly one of x and y should be numeric, and the other a factor or shingle**. Which of these will happen is determined by the horizontal argument — if horizontal=TRUE, then y will be coerced to be a factor or shingle, otherwise x. The default value of horizontal is FALSE if x is a factor or shingle, TRUEotherwise. (The functionality provided by horizontal=FALSE is not S-compatible.) So with the default ... horizontal = FALSE, Med would be treated as a factor, which I think is precisely the opposite of what you want. Here is a simple example to indicate how things work: y <- runif(5) x <- factor(letters[1:5]) barchart(y~x) As for fiddling with the colors and patterns of the bars -- generally a bad idea , especially fill patterns, btw -- see the "col" argument of ?panel.barchart, which is always where you should look for such info (i.e. panel.whatever). I don't know whether you can fool with fill patterns* -- it may depend on your graphics device -- but you can google around or see what trellis.par.get() has available (which can be specified in the "par.settings" argument list in the call). * For why fooling with fill patterns is a bad idea, google "moiré patterns". Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Aug 22, 2018 at 8:13 AM Rich Shepard <rshep...@appl-ecosys.com> wrote: > I've not before created bar charts, only scatter plots and box plots. > Checking in Deepayan's book, searching the web, and looking at ?barchart > has > not shown me the how to get the results I need. > > The dataframe looks like this: > > head(stage_heights) > Year Med Max > 1 1989 91.17 93.32 > 2 1990 91.22 93.43 > 3 1991 91.24 92.89 > 4 1993 91.14 93.02 > 5 1994 93.92 95.74 > 6 1995 94.34 96.85 > > I want to show Med and Max heights for each Year with each bar having a > different color (or pattern) and a single x-axis year label. > > Trying to follow the example in ?barchart for a single variable > produced this: > > > barchart('Year' ~ 'Med', data=stage_height, > panel=lattice.getOption('panel.barchart'), > default.prepanel=lattice.getOption('prepanel.default.barchart'),box.ratio=2) > Error in eval(substitute(groups), data, environment(formula)) : > invalid 'envir' argument of type 'closure' > and no plot was displayed. > > I must be missing the obvious and want a pointer to descriptions that > teach me how to produce bar charts. > > Rich > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.