[R] How to improve a function converting year, day of year, decimal hour into date ?

Ptit_Bleu ptit_bleu at yahoo.fr
Tue Nov 20 12:53:10 CET 2007


Hi,

I would like to "build" a date from a year, a day of the year and a decimal
hour.
Ex : reconst_date(2007,324,12.50) gives "2007-11-20 12:30:0"

The following function is doing this job but I would like to know if there
is a function which directly converts the decimal hours into
hours:minutes:secondes ?

Thanks for your help,
Have a nice day,
Ptit Bleu.

--------------------

reconst_date<-function(annee, jour, heured) {
str_anneejour<-paste(annee,jour,sep=" ")
str_anneemoisjour<-strptime(str_anneejour, "%Y %j")
heure<-trunc(heured)
minute<-trunc((heured-heure)*60)
seconde<-((heured-heure)*60-minute)*60
seq_dateR<-paste(str_anneemoisjour,"
",heure,":",minute,":",round(seconde),sep="")
return(seq_dateR)
}
-- 
View this message in context: http://www.nabble.com/How-to-improve-a-function-converting-year%2Cday-of-year%2Cdecimal-hour-into-date---tf4843032.html#a13855563
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list