[R] Extracting File Basename without Extension

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Sun Jan 11 10:14:01 CET 2009


Gabor Grothendieck wrote:
> On Fri, Jan 9, 2009 at 4:20 PM, Wacek Kusnierczyk
>
>   
>> right;  there's a straightforward fix to my solution that accounts for
>> cases such as '.bashrc':
>>
>> names = c("foo.bar", ".zee")
>> sub("(.+)[.][^.]+$", "\\1", names)
>>
>> you could also use a lookbehind if possible (not in r, afaik).
>>
>>     
>
> or:
>
>   
>> sub(".*[.]", ".", names)
>>     
> [1] ".bar" ".zee"
>   

it was "foo" that was desired...

vQ




More information about the R-help mailing list