Skip to content

Using dates for plotting

3 messages · Christoph Lange, Brian Ripley, PIKAL Petr

#
Dear R-Users!

I have the following data:
dates kms
1 2004-01-15 12:00:00   9
2 2004-01-16 12:00:00  10
3 2004-01-17 12:00:00   5
[1] "POSIXt"  "POSIXct"
Is it possible to _easily_ plot these data with real dates shown as
tick marks on the x-axis? Perhaps even when the days are not
continuous but with missing days in between?

Thanks in advance,

  Christoph.
#
On Fri, 16 Jan 2004, Christoph Lange wrote:

            
Yes.  ?plot.POSIXct has examples like

     plot(.leap.seconds, 1:22, type="n", yaxt="n",
          xlab="leap seconds", ylab="", bty="n")
     rug(.leap.seconds)

What could be easier?  If you want only the data dates labelled, use
axis.POSIXct.
#
Hi
On 16 Jan 2004 at 12:01, Christoph Lange wrote:

            
plot(dates,kms)

should work, but you need to do some formating (maybe with 
axes=F and axis())

see ?strptime

and to convert your dates to POSIXct gformat
					 ^^
Beware "dates" is a function name in library chron.

HTH Petr
Petr Pikal
petr.pikal at precheza.cz