[R] help with gsub and date pattern

Tim Clark mudiver1200 at yahoo.com
Thu May 21 23:13:10 CEST 2009


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 that the / is a special character and is telling it something that I don't mean.  I would appreciate any suggestions on how to proceed.

Thanks,

Tim



Tim Clark
Department of Zoology 
University of Hawaii




More information about the R-help mailing list