Hi everybody,
 
Thank you for the suggestions and especially the explanation Waclaw provided 
for his code. Maybe one day i will be able to wrap my head around this.
 
Thanks again,
 
Monica

----------------------------------------
> Date: Tue, 26 May 2009 15:46:21 +0200
> From: waclaw.marcin.kusnierc...@idi.ntnu.no
> To: pisican...@hotmail.com
> CC: r-help@r-project.org
> Subject: Re: [R] split strings
>
> Monica Pisica wrote:
>> 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"
>
> one way that seems reasonable is to use sub:
>
> output = sub('.*//(.*)[.]tif$', '\\1', input)
>
> which says 'from each string remember the substring between the
> rigthmost two slashes and a .tif extension, exclusive, and replace the
> whole thing with the captured part'. if the pattern does not match, you
> get the original input:
>
> sub('.*//(.*)[.]tif$', '\\1', 'f:/foo/bar//buz.tif')
> # buz
>
> vQ
_________________________________________________________________
HotmailĀ® goes with you. 

ial_Mobile1_052009
______________________________________________
R-help@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.

Reply via email to