Re: [R] gsub syntax help

2012-02-02 Thread Benjamin Caldwell
Oh, perfect. I was running gsub(".sample.tif", "", avec). your change gsub("\\.sample\\.tif$", "", avec) did it. Thanks Sarah *Ben Caldwell* On Thu, Feb 2, 2012 at 1:48 PM, Sarah Goslee wrote: > In the example you gave, all that has to be done is > replace ".sample.tif" at the end of the

Re: [R] gsub syntax help

2012-02-02 Thread Sarah Goslee
In the example you gave, all that has to be done is replace ".sample.tif" at the end of the string with "", which is easy. > avec <- c("SPI1.S1.str1.P3.sample.tif", "SPI1.S1.STR2.P1.sample.tif") > gsub("\\.sample\\.tif$", "", avec) [1] "SPI1.S1.str1.P3" "SPI1.S1.STR2.P1" If your real data are mo

[R] gsub syntax help

2012-02-02 Thread Benjamin Caldwell
I have some elements in a vector with extraneous information (e.g. file name and sample IDs) that I'd like to strip from every element. For example, I would like "SPI1.S1.str1.P3.sample.tif" "SPI1.S1.STR2.P1.sample.tif" to read "SPI1.S1.str1.P3" "SPI1.S1.STR2.P1". Will someone help me with the