[R] Time in ggplot2
Hadley Wickham
hadley at rice.edu
Mon Jun 21 05:40:10 CEST 2010
Hi Jeff,
I am not aware of any problems with POSIXct and ggplot2, so I'm not
sure what you're referring to. I don't ask for reproducible examples
to be malicious - they make it easier for me to figure out exactly
what's wrong and recommend a fix. Without a simple reproducible
example, all I can do is guess at what the problem is, and my guesses
aren't always very accurate!
Hadley
On Sun, Jun 20, 2010 at 9:40 PM, Jeff Newmiller
<jdnewmil at dcn.davis.ca.us> wrote:
> That's a bit disingenuous, Hadley. There have been reports of problems with POSIXct and ggplot2 for at least six months, particularly with values that have no time portion. You have promised a fix before, but l haven't seen it, so I convert to Date to work around the bug.
>
> "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/
>>
>>______________________________________________
>>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.
>
> ---------------------------------------------------------------------------
> Jeff Newmiller The ..... ..... Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
> Live: OO#.. Dead: OO#.. Playing
> Research Engineer (Solar/Batteries O.O#. #.O#. with
> /Software/Embedded Controllers) .OO#. .OO#. rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>
> ______________________________________________
> 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/
More information about the R-help
mailing list