On Thu, Oct 16, 2008 at 11:42 AM, x0rr0x <[EMAIL PROTECTED]> wrote: > > Hi all, > > I'm trying to create a histogram which shows the frequency of variables > within a certain timeframe. > > I've been using SPSS before, but I didn't quite like it... > > To describe my problem further here are some example variables: > > the "event" is actually a string which I recoded using: > [code] > data$event_class = as.numeric(as.factor(data$event)) > [/code] > I've recoded them into numerics > > > csv: > [code] > time,event,event_class > 01,cookies,1 > 05,cookies,1 > 06,pie,2 > 07,coffee,3 > 08,cookies,1 > 30,pie,2 > 31,coffee,3 > [/code] > and so on... > > Now I'd like to create a histogram where X is the time, the color of the > area is the event_class > and Y is defined by the frequency of event_class around some accumulated > time
install.packages("ggplot2") library(ggplot2) qplot(time, fill = event, data = mydata, geom = "histogram") You can find out more about ggplot2 at http://had.co.nz/ggplot2 - it's inspired by the Grammar of Graphics, which is also the theory that underlies SPSS's plotting systems. Hadley -- http://had.co.nz/ ______________________________________________ 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.