[R] search and replace in a list of strings

jim holtman jholtman at gmail.com
Mon Jul 26 16:03:31 CEST 2010


The most "usable" form is to convert it to POSIXct since most of the
plotting routines know how to handle date/time.  You could do:

myDate <- as.POSIXct(paste(WD$date, WD$time), format='%m.%d.%Y %H:%M:%S')


e.g.,
> as.POSIXct('07.07.2010 12:34:15', format='%m.%d.%Y %H:%M:%S')
[1] "2010-07-07 12:34:15 EDT"


On Mon, Jul 26, 2010 at 9:07 AM, Olivier Coupiac
<Olivier.Coupiac at renerco.com> wrote:
> Hi everybody,
>
> I have a 4*4 matrix WD of wind data of the following form:
>
>> WD
> $date
> [1] "07.07.2010" "07.07.2010" "07.07.2010" "07.07.2010"
>
> $time
> [1] "00:00:00" "00:10:00" "00:20:00" "00:30:00"
>
> $CH1Avg
> [1] 3.02 3.04 2.94 2.71
>
> I would like to transform the date and time strings in usable numbers for plotting :
>
> -          Transform "07.07.2010" in 07*24 + 07*31*24   for example
>
> -          Transform the string of type "12:15:20" in a number equals to 12+15/60+20/3600
>
> I would hence need a function able to look for defined patterns in a list, like aa:bb:cc and evaluate aa+bb/60+cc/3600.
>
> Anyone has a idea?
>
> Thanks a lot!
> Cheers
>
> Olivier Coupiac
>
>        [[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?



More information about the R-help mailing list