Hello all,

I am having a little trouble working with "strptime" and I was hoping
someone might be able to give me a hand. I have an instrument that outputs
an ordinal date and time in two columns something like this:

  day.hour min.sec
1    12525    2050
2    12518    2029
3    12524    2023
4    12524    2028
5    12507    2035

Now the problem I am having is converting these numbers into dates and
times. I am able to convert these into their respective POSIXlt formats but
I am left with two columns where hour is left with the date (data$Only.Date)
and the date is left with the time (data$Only.Time). Can anyone recommend a
good way to convert these ordinal dates into something like the following?

day.hour     min.sec    Date            Time
12511         2033        2011-05-05   11:20:33

## A trivial example
##a data frame
day.hour <-as.integer(runif(5, 12500, 12523)) #First 3 digits are the day of
the year, last 2 are the hour of the day
data <- as.data.frame(day.hour)
data$min.sec <-as.integer(runif(5, 2000, 2060)) #First 2 digits are the
minute, last 2 are the seconds

##example of how things get a little jumbled. strptime was easy enough to
use.
data$Date <- strptime(data$day.hour, format="%j%H")
data$Time <- strptime(data$min.sec, format="%M%S")
data

Using Ubuntu 10.10 and R 2.11.1. Thanks in advance!!!!

Sam

-- 
*****************************************************
Sam Albers
Geography Program
University of Northern British Columbia
3333 University Way
Prince George, British Columbia
Canada, V2N 4Z9
*****************************************************

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to