Skip to content
Prev 277371 / 398506 Next

gsub help

Hi,
On Mon, Nov 14, 2011 at 7:59 PM, Debs Majumdar <debs_stata at yahoo.com> wrote:
So you want the file name that starts with study and ends in 1?

I'd use grep() rather than gsub(), since you just want to match from a
list, or is there more going on than in your example?

You didn't give a reproducible dataset, but here's a fake one,
matching strings that begin with "a" instead of "study", and ending
with "1" as in your example:
[1] "abcd1"

You might really just need
yourdata[grepl("1$", yourdata)]
to select filenames that end in 1.

If that's all you really need, you've made it far too complicated.

Sarah