[R] Grouped bar plot

From: jctoll <jctoll_at_gmail.com>
Date: Wed, 18 May 2011 13:13:24 -0500


I am trying to produce a grouped bar plot from a data.frame and I'm having difficulties figuring out how to do so. My data is 500 rows by 4 columns and basically looks like so:

> head(x)

    V1 V2 V3 V4

1  XOM 0.2317915 0.1610068 1.6941637
2 AAPL 0.6735488 0.7433611 0.1594102
3   GE 1.2554160 0.9237384 1.6767711
4  IBM 1.6296938 0.3730387 0.5858115
5  CVX 0.9194169 0.4785705 0.1803601
6   PG 0.7768241 1.7622060 0.7640163

 . . .

I would like to produce something similar to what is found at: http://www.statmethods.net/graphs/bar.html # the grouped barplot example

http://had.co.nz/ggplot2/geom_bar.html                # the Dodged bar
charts example

Across the X-axis, for each set(row) of 3 data points(V2, V3, V4) associated with a symbol(V1), I would like to create a group of 3 bars reflecting their values. So the Y-axis will represent the magnitude of values in the columns (V2, V3, V4), and X-axis will have 500 groups of 3 bars, for a total of 1500 bars. I would like the color of each bar to reflect the column of data it represents, and to label each group of 3 with the corresponding symbol in column V1.

I was trying to get this to work using ggplot but the y-axis in the example is the count, which is not what I'm after. Any suggestions, to get me started down the right path would be appreciated. Thank you.


R-help_at_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. Received on Wed 18 May 2011 - 18:15:16 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 18 May 2011 - 20:00:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive