[R] how to parse out string separated by special character

xin wei xinwei at stat.psu.edu
Mon Jun 7 19:21:07 CEST 2010


hi, everyone:
i have a data frame with one single character column as followings:
DS_xxx_yyy_24hr_zzz_1
DS_xxx_yyy_24hr_zzz_2
DS_xxx_yyy_24hr_zzz_3
DS_xxx_yyy_24hr_zzz_4
DS_xxx_yyy_24hr_zzz_1
DS_xxx_yyy_24hr_zzz_2
DS_xxx_yyy_24hr_zzz_3
DS_xxx_yyy_24hr_zzz_4
DS_xxx_yyy_24hr_zzz_1

i need to parse out the time part like the followings:
name                               time
DS_xxx_yyy_24hr_zzz_1      24hr
DS_xxx_yyy_24hr_zzz_2      24hr      
DS_xxx_yyy_24hr_zzz_3      24hr
DS_xxx_yyy_24hr_zzz_4      24hr
DS_xxx_yyy_24hr_zzz_1      24hr
DS_xxx_yyy_24hr_zzz_2      24hr
DS_xxx_yyy_24hr_zzz_3      24hr
DS_xxx_yyy_24hr_zzz_4      24hr
DS_xxx_yyy_24hr_zzz_1      24hr

what function should I look at?
i have tried: strsplit(data, '_') and get a giant list which is not what i
need.

thanks in advance

-- 
View this message in context: http://r.789695.n4.nabble.com/how-to-parse-out-string-separated-by-special-character-tp2246301p2246301.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list