Re: [R] strptime and plot(),lines()

From: Don MacQueen <>
Date: Thu, 27 Mar 2008 08:34:50 -0700

As Gabor said, your zeit should be a POSIXct object, not a POSIXlt object.

Then, for example:

   zeit <- Sys.time() + 1500000*runif(10)    val <- rnorm(10)
   axis.POSIXct(1,zeit, format='%Y-%m-%d %H:%M')

Or better (perhaps) yet:

   axis.POSIXct(1,zeit, format='%Y-%m-%d\n%H:%M', mgp=c(3,2,0))

However, depending on the overall time range, this example might make more sense:

   zeit <- Sys.time() + 15000*runif(10)
   axis.POSIXct(1,zeit, format='%Y-%m-%d\n%H:%M', mgp=c(3,2,0))

> class(zeit)

[1] "POSIXt" "POSIXct"


At 2:59 PM +0100 3/27/08, erkan yanar wrote:
>Im reading Data out of a Database.
>rs <- dbGetQuery(con,"SELECT * ... )
>There ist a colum I convert into "Time".
>> zeit<-strptime(datum,format="%Y-%m-%d %H:%M:%S");
>> class(zeit)
>[1] "POSIXt" "POSIXlt"
>A plot(zeit,money) plots the Data.
>All i see on the x-achis are the Days.
>I would like to see the hours also.
>length(zeit) gives mit the length of one entry.
>But zeit exists of 500 entries.
>How can i get the amount of entries zeit got?
>Im used to draw whith lines() into an existing plot.
>But something like lines(zeit,food) wouldnt work.
>All this works quit well, when Im using unixtime. But seconds since
>1970 are not that nice on the x-achis:-)
>Erkan Yanar
>über den grenzen muß die freiheit wohl wolkenlos sein
> mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 27 Mar 2008 - 19:39:13 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 Thu 27 Mar 2008 - 20:30:24 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive