library(chron) chron(paste("1/1/", year, sep = "")) + julday + hour/24
That produces a chron, i.e. dates/times class datetime. If you want it as a string use format(...above expression...) See the help desk article in R News 4/1. On Nov 20, 2007 6:53 AM, Ptit_Bleu <[EMAIL PROTECTED]> wrote: > > 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. > > ______________________________________________ > 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. > ______________________________________________ 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.