[R] working with strptime data

Gabor Grothendieck ggrothendieck at gmail.com
Fri Sep 15 02:15:42 CEST 2006


Read the help desk article in R News 4/1.

On 9/14/06, Richard Evans <revans at jlab.org> wrote:
> Dear R-forum,
>
> I am looking for a good resource/help on working with POSIXct values and
> controlling the pretty x-axis labels and tick marks for a data VS time
> plots. Specifically, I wish to do programming logic which creates
> different vertical ablines calculations based on the range of times
> which i am working on. The default plot results are adequate, but I
> would love to make explicit calls on how the x-axis annotates the
> timestamps.
>
> Does anyone have example code or know of a good reference for these
> kinds of R-programming tasks?
>
>
> Here's a simplified example:
> ----------------------------------------------------------
> I have a large data set that consists of N pairs of values and
> timestamps strings.
> Like this:
>
> TheData <- c(1.2,             0.9,             etc...[to the Nth
> datapoint])
> TheTime <- c("9/1/2006 8:00", "9/1/2006 8:13", etc...[to the Nth
> timestamp])
>
> I convert the timestamp strings into POSIXct types as:
>
> TheTime <- as.POSIXct(strptime(TheTime, format="%m/%d/%Y %H:%M"))
>
> And create a plot as such:
>
> plot(MyTime,MyData)
>
> ----------------------------------------------------------
>
> And here is a specific question:
>
> How do I calculate the number of months than are spanned between two
> POSIXct values?
> (i.e. NumOfMonths <- MonthFunction(range(MyTimeStampData))
>
> Thanks-in-advance,
> - rich
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list