Re: [R] Histogram with two colors depending on condition

2008-07-17 Thread Greg Snow
to:[EMAIL PROTECTED] On Behalf Of Mohammad > Ehsanul Karim > Sent: Thursday, July 17, 2008 3:13 AM > To: r-help@r-project.org > Subject: [R] Histogram with two colors depending on condition > > Dear List, > > Say, we generate data like this- > > dat<-rnorm(1000,

Re: [R] Histogram with two colors depending on condition

2008-07-17 Thread hadley wickham
On Thu, Jul 17, 2008 at 5:13 PM, Mohammad Ehsanul Karim <[EMAIL PROTECTED]> wrote: > Dear List, > > Say, we generate data like this- > > dat<-rnorm(1000,1,2) > hist(dat) library(ggplot) qplot(dat, geom="histogram", colour = factor(dat < 0)) Hadley -- http://had.co.nz/

Re: [R] Histogram with two colors depending on condition

2008-07-17 Thread jim holtman
Here is something that is close: > x <- rnorm(1) > y <- hist(x, plot=FALSE) > plot(y, col=ifelse(y$mid<0,'red','green')) > On Thu, Jul 17, 2008 at 5:13 AM, Mohammad Ehsanul Karim <[EMAIL PROTECTED]> wrote: > Dear List, > > Say, we generate data like this- > > dat<-rnorm(1000,1,2) > hist(dat)

[R] Histogram with two colors depending on condition

2008-07-17 Thread Mohammad Ehsanul Karim
Dear List, Say, we generate data like this- dat<-rnorm(1000,1,2) hist(dat) How do i make the histogram, say, red (col = 2) before X = dat = 0, and rest say, green (col = 3) beyond X = dat = 0 in R? The resulting histogram could be like this http://ehsan.karim.googlepages.com/histogram.JPG (e