Re: [R] Putting a loop in a function

2011-04-02 Thread Ben Hunter
Thanks so much Josh. That absolutely does help. I was just stuck on the function regexpr and didn't consider how handy the other string handling functions would be. As far as attaching 'i' to 'vector', that was indeed a typo. As I was going through my code to make it more readable (at least that wa

Re: [R] Putting a loop in a function

2011-04-02 Thread Berend Hasselman
Ben Hunter wrote: > > I'm stuck here. The following code works great if I just use it on the > command line in a 'for' loop. Once I try to define it as a function as > seen > below, I get bad results. I'm trying to return a vector of column indices > based on a short string that is contained in a

Re: [R] Putting a loop in a function

2011-04-01 Thread Joshua Wiley
Hi Ben, I am having some trouble figuring out what it is exactly you want. A workable example would be nice and then (even if just manually) typed out what you would like it to return based on a given input. I almost think you just want grep(). grep("test", c("test", "not", "test2", "not"), val

[R] Putting a loop in a function

2011-04-01 Thread Ben Hunter
I'm stuck here. The following code works great if I just use it on the command line in a 'for' loop. Once I try to define it as a function as seen below, I get bad results. I'm trying to return a vector of column indices based on a short string that is contained in a selection (length of about 70)