Re: [R] help with gsub and date pattern

2009-05-21 Thread Gabor Grothendieck
Here are a few more to add to the list. x <- c("5/31/2009 12:34:00","6/1/2009 1:14:00") # 1 read.table(textConnection(x), as.is = TRUE)[, 2] # 2 format(as.POSIXct(x, format = "%m/%d/%Y %H:%M:%S"), "%H:%M:%S") # 3 library(gsubfn) strapply(x, "[0-9]*:..:..", simplify = c) Also see R News 4/1.

Re: [R] help with gsub and date pattern

2009-05-21 Thread Tim Clark
Thanks for the help and the various options! Putting the + outside the brackets worked, but I like the strsplit option. Always nice to learn new functions! Aloha, Tim --- On Thu, 5/21/09, Marc Schwartz wrote: > From: Marc Schwartz > Subject: Re: [R] help with gsub and date p

Re: [R] help with gsub and date pattern

2009-05-21 Thread Marc Schwartz
On May 21, 2009, at 4:13 PM, Tim Clark wrote: Dear List, I am having a problem using gsub to remove dates from a date/time string. For example: x<-c("5/31/2009 12:34:00","6/1/2009 1:14:00") I would like to remove the date and have just the time. I have tried: gsub("[0-9+]/[0-9+]/[0-9+]"

[R] help with gsub and date pattern

2009-05-21 Thread Tim Clark
Dear List, I am having a problem using gsub to remove dates from a date/time string. For example: x<-c("5/31/2009 12:34:00","6/1/2009 1:14:00") I would like to remove the date and have just the time. I have tried: gsub("[0-9+]/[0-9+]/[0-9+]","",x) and various versions. I think my problem is