Message-ID: <BAY130-W260FD8C24AA6B865027A0BC3520@phx.gbl>
Date: 2009-05-26T13:27:22Z
From: Monica Pisica
Subject: split strings
Hi everybody,
I have a vector of characters and i would like to extract certain parts. My vector is named metr_list:
[1] "F:/Naval_Live_Oaks/2005/data//BE.tif"
[2] "F:/Naval_Live_Oaks/2005/data//CH.tif"
[3] "F:/Naval_Live_Oaks/2005/data//CRR.tif"
[4] "F:/Naval_Live_Oaks/2005/data//HOME.tif"
And i would like to extract BE, CH, CRR, and HOME in a different vector named "names.id" for example. I read the help files for sub and grep and the likes but i have to recognize that i did not understand it. So i've done this (which does the job but extremely clumsy):
b <- strsplit(metr_list, "//")
b <- unlist(b)
d <- strsplit(b, "\\.")
d <- unlist(d)
names.id <- d[c(2, 5, 8, 11)]
Can anybody show what would be the proper way to achieve this with some explanations?
Thanks,
Monica
_________________________________________________________________
Hotmail? goes with you.
ial_Mobile1_052009