mgilgen at swissonline.ch wrote:> Hi there
>
> I have precipitation data from 2004 to 2006 in varying resolutions (10 to
20min intervals) with time in seconds from beginnig of the year (summation) and
a second variable as year.
>
> I applied follwing code to convert the time into a date:
>
> times<-strptime("2004-01-01", "%Y-%m-%d",
tz="GMT") + precipitation$time1
>
> everytihng went well, except that every year, the seconds-counter starts by
zero, therefore I have now three 2004 series instead of going further from 04 to
05 etc.
>
> I tried to sum the last seconds-values of 2004 to the first of 2005 with an
if command like:
>
> if (year=2005) time2=time1+632489 ;(seconds)
>
> but it doesn't work.
>
> thanks for a solution
>
Can't you just do strptime(paste(year, "01-01",
sep="-"),.... ? (or use
ISOdatetime(year,1,1,0,0,0,tz="GMT"))