hi, I have my data time expressed in character string exple "5:20" (hour:min) and i want to convert these in times recognized by R. I have tried the POSIXct function: balise07$Hour <- as.POSXIct(balise07$Hour) but it didn't work. Do you know why? Do you know how i can convert my string character in a real time? Thanks Karine HEERAH Master 2 mention "océanographie et environnements marins", parcours océanique 42 rue Salvador Allende 92000 Nanterre 06.61.50.97.47 _________________________________________________________________ [[alternative HTML version deleted]]
> hi, > > > > I have my data time expressed in character string exple "5:20" (hour:min) and i want to convert these in times recognized by R. I have tried the POSIXct function: > > > > balise07$Hour <- as.POSIXct(balise07$Hour) > > > > but it didn't work. > > Do you know why? Do you know how i can convert my string character in a real time? > > > > Thanks > > Karine HEERAH > > Master 2 mention "océanographie et environnements marins", parcours océanique > > 42 rue Salvador Allende > 92000 Nanterre > 06.61.50.97.47 > > > > > _________________________________________________________________ > > > [[alternative HTML version deleted]] >_________________________________________________________________ [[alternative HTML version deleted]]
Try this:> as.POSIXct("5:30", format="%H:%M")[1] "2010-02-03 05:30:00 EST" On Wed, Feb 3, 2010 at 8:27 AM, karine heerah <karine.heerah at hotmail.fr> wrote:> > hi, > > > > I have my data time expressed in character string exple "5:20" (hour:min) and i want to convert these in times recognized by R. I have tried the POSIXct function: > > > > balise07$Hour <- as.POSXIct(balise07$Hour) > > > > but it didn't work. > > Do you know why? Do you know how i can convert my string character in a real time? > > > > Thanks > > Karine HEERAH > > Master 2 mention "oc?anographie et environnements marins", parcours oc?anique > > 42 rue Salvador Allende > 92000 Nanterre > 06.61.50.97.47 > > > > > _________________________________________________________________ > > > ? ? ? ?[[alternative HTML version deleted]] > > > ______________________________________________ > R-help at 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. > >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Try this (and see R News 4/1):> library(chron) > tt <- times(paste("5:20", "00", sep = ":")); tt[1] 05:20:00> tt + 12/24 # add 12 hours[1] 17:20:00 On Wed, Feb 3, 2010 at 8:27 AM, karine heerah <karine.heerah at hotmail.fr> wrote:> > hi, > > > > I have my data time expressed in character string exple "5:20" (hour:min) and i want to convert these in times recognized by R. I have tried the POSIXct function: > > > > balise07$Hour <- as.POSXIct(balise07$Hour) > > > > but it didn't work. > > Do you know why? Do you know how i can convert my string character in a real time? > > > > Thanks > > Karine HEERAH > > Master 2 mention "oc?anographie et environnements marins", parcours oc?anique > > 42 rue Salvador Allende > 92000 Nanterre > 06.61.50.97.47 > > > > > _________________________________________________________________ > > > ? ? ? ?[[alternative HTML version deleted]] > > > ______________________________________________ > R-help at 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. > >