Hi:

Here are some possibilities using ggplot2:

library(ggplot2)

# Create ordered factors
bar$area2 <- ordered(bar$area)
bar$year2 <- ordered(bar$year)

# Side-by-side, aka dodged, bar charts
ggplot(bar, aes(x = area2, y = disc, fill = year2)) +
     geom_bar(aes(group = year2), position = 'dodge', stat = 'identity')

# Faceted bar charts (same idea as Gabor's in lattice)
ggplot(bar, aes(x = year2, y = disc)) +
     geom_bar(fill = 'blue', stat = 'identity') + facet_wrap(~ area2)

# This seems a more informative display, however:
ggplot(bar, aes(x = area2, y = disc, colour = year2)) +
     geom_point() + geom_line(aes(group = year), size = 1) +
     scale_colour_discrete('Year') + xlab('Area')

# A lattice version is
xyplot(disc ~ area2, data = bar, groups = year, type = c('p', 'a'),
       lwd = 2, xlab = 'Area', key = simpleKey(corner = c(0.2, 0.45),
          text = levels(bar$year2), lines = TRUE, points = FALSE))

Note that corner = c(0, 1) is upper left and c(1, 0) is lower right, for
example, assuming you want to change the location of the legend.

HTH,
Dennis

On Tue, Nov 23, 2010 at 11:49 AM, Art Burke <
Art.Burke@educationnorthwest.org> wrote:

> Given the data structure below, how can I create a bar plot for the values
> of disc for each area grouped by year?
>
> bar <-structure(list(year = c(2003, 2003, 2003, 2003, 2003, 2003, 2003,
> 2007, 2007, 2007, 2007, 2007, 2007, 2007), area = structure(c(6L,
> 4L, 1L, 2L, 3L, 5L, 7L, 6L, 4L, 1L, 2L, 3L, 5L, 7L), .Label = c("AK",
> "ID", "MT", "NW", "OR", "US", "WA"), class = "factor"), disc = c(55.8,
> 62.6, 54.3, 56.9, 52.8, 66.7, 64.8, 59.5, 64.8, 65.8, 61.4, 60.6,
> 66.3, 65.5)), .Names = c("year", "area", "disc"), class = "data.frame",
> row.names = c(NA,
> 14L))
>
> Thanks!
> Art
>
> ______________________________________________
> R-help@r-project.org mailing list
> 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]]

