Re: [R] Time in ggplot2

From: Ottar Kvindesland <ottar.kvindesland_at_gmail.com>
Date: Tue, 22 Jun 2010 16:23:38 -0400

Excellent, thanks. This solved it.

ottar

On 22 June 2010 11:39, Hadley Wickham <hadley_at_rice.edu> wrote:

> Hi Ottar,
>
> It's a bug in the code that automatically figures out the axis ticks.
> I have some code to fix it, but it's waiting for a release of another
> package. In the meantime, you can work around it by specifying where
> you want the breaks:
>
> ggplot(data, aes(time, PU) ) +
> geom_line() +
> scale_x_datetime(major = "3 hours")
>
> Hadley
>
> PS. You can make the code completely reproducible with (e.g.)
> load(url("http://master.kvindesland.no/R/failed_data.Rdata"))
>
> On Mon, Jun 21, 2010 at 3:24 PM, Ottar Kvindesland
> <ottar.kvindesland_at_gmail.com> wrote:
> > Thanks Hadley for taking the interest here.
> >
> > The data sets are a bit large and I have placed them available for your
> > download on
> > http://master.kvindesland.no/R/
> > You will find datasets in both Rdata and dput format. It seems that some
> > data sets works nicely and others do not even if they come from a very
> > similar SQL set. The select clause carries more coloumns in the failing
> data
> > set.
> >
> > ottar
> >
> > On 20 June 2010 18:28, Hadley Wickham <hadley_at_rice.edu> wrote:
> >>
> >> Hi Ottar,
> >>
> >> It's impossible to tell what the problem is without a reproducible
> >> example (http://gist.github.com/270442)
> >>
> >> Hadley
> >>
> >> On Sun, Jun 20, 2010 at 4:38 PM, Ottar Kvindesland
> >> <ottar.kvindesland_at_gmail.com> wrote:
> >> > I have a problem that puzzles me a bit today. When loading off data
> from
> >> > a
> >> > database and plotting using ggplot2, I wish to present data as a time
> >> > series
> >> > with time of day. The code is text-book like as shown below:
> >> >
> >> > # Fetch data
> >> > con <- dbConnect(dbDriver("MySQL"), user="user", password = "pwd",
> >> > dbname="db")
> >> > data <- dbGetQuery(con, "select PU, DateTime from rep;")
> >> > data$time <- as.POSIXct(data$DateTime)
> >> > attach(data)
> >> >
> >> > # Plot Data
> >> > p <- ggplot(data, aes(x=time, colour=PU ) ) +
> >> > ylim( c(0, max(PU)) ) +
> >> > geom_line( aes(x=time, PU ) )
> >> >
> >> > p
> >> >
> >> > It starts plotting and terminates before anything is drawn on the
> >> > canvas.
> >> > The error message on the terminal is:
> >> >
> >> > Error in seq.int(0, to - from, by) : 'to' must be finite
> >> >
> >> > The DateTime coloumn in MySQL is of type datetime Is it a bug or a
> >> > feature?
> >> >
> >> >
> >> >
> >> > Thanks
> >> >
> >> > ottar
> >> >
> >> > [[alternative HTML version deleted]]
> >> >
> >> > ______________________________________________
> >> > 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.
> >> >
> >>
> >>
> >>
> >> --
> >> Assistant Professor / Dobelman Family Junior Chair
> >> Department of Statistics / Rice University
> >> http://had.co.nz/
> >
> >
>
>
>
> --
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
>

        [[alternative HTML version deleted]]



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 Tue 22 Jun 2010 - 20:26:01 GMT

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 Tue 22 Jun 2010 - 20:31:26 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