Hi I have two questions about using ggplot2. First, I have multiple columns of data that I would like to combine into one histogram where each column of data would correspond to one bar in the histogram. Each column has 0 or 1s and I want my bars in the histogram to correspond to the sum of the 1s in each column. Does that make sense? Second, is there a way to completely turn off the legend? Thanks! Chris PS - Please cc me on the email as I'm a digest subscriber.
Questions about ggplot2
2 messages · Christopher David Desjardins, Juliet Hannah
2 days later
I started with the summarized data, and there are different ways to do
this. For this example, let there be four columns and a corresponding
sum of 1s.
library("ggplot2")
mydf <- data.frame(colname = c("A","B","C","D"),mycolsum=c(1:4))
p <- ggplot(mydf,aes(x=colname,y=mycolsum))
p <- p + geom_bar(stat = "identity")
# Here is one way a legend would be created, and how to remove it.
library("ggplot2")
mydf <- data.frame(colname = c("A","B","C","D"),mycolsum=c(1:4))
p <- ggplot(mydf,aes(fill=colname, x=colname,y=mycolsum))
p <- p + geom_bar(stat = "identity")
p + opts(legend.position = "none")
On Thu, May 13, 2010 at 11:33 AM, Christopher David Desjardins
<cddesjardins at gmail.com> wrote:
Hi I have two questions about using ggplot2. First, I have multiple columns of data that I would like to combine into one histogram where each column of data would correspond to one bar in the histogram. Each column has 0 or 1s and I want my bars in the histogram to correspond to the sum of the 1s in each column. Does that make sense? Second, is there a way to completely turn off the legend? Thanks! Chris PS - Please cc me on the email as I'm a digest subscriber.
______________________________________________ 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.