Re: [R] help with dealing with integer(0) returns from grep used within a conditional loop

2009-07-04 Thread Mark Kimpel
Thanks, embarrased that I didn't think of that myself :) Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, & Mobile & VoiceM

Re: [R] help with dealing with integer(0) returns from grep used within a conditional loop

2009-07-04 Thread Duncan Murdoch
On 04/07/2009 6:09 PM, Henrique Dallazuanna wrote: You cas use isTRUE: isTRUE(grep("a", "") > 0) Not really. If there are multiple hits, that returns FALSE. You want to use length(grep(...)) to detect any hits. Duncan Murdoch On Sat, Jul 4, 2009 at 2:56 PM, Mark Kimpel wrote: I

Re: [R] help with dealing with integer(0) returns from grep used within a conditional loop

2009-07-04 Thread Henrique Dallazuanna
You cas use isTRUE: isTRUE(grep("a", "") > 0) On Sat, Jul 4, 2009 at 2:56 PM, Mark Kimpel wrote: > I am using grep to locate colnames to automate a report build and have > run into a problem when a colname is not found. The use of integer(0) > in a conditional statement seems to be a no no

Re: [R] help with dealing with integer(0) returns from grep used within a conditional loop

2009-07-04 Thread hadley wickham
On Sat, Jul 4, 2009 at 7:56 PM, Mark Kimpel wrote: > I am using grep to locate colnames to automate a report build and have > run into a problem when a colname is not found. The use of integer(0) > in a conditional statement seems to be a no no as it has length 0. > Below is a self-contained trivia

Re: [R] help with dealing with integer(0) returns from grep used within a conditional loop

2009-07-04 Thread Allan Engelhardt
On 04/07/09 18:56, Mark Kimpel wrote: I am using grep to locate colnames to automate a report build and have run into a problem when a colname is not found. The use of integer(0) in a conditional statement seems to be a no no as it has length 0. Below is a self-contained trivial example. I woul

[R] help with dealing with integer(0) returns from grep used within a conditional loop

2009-07-04 Thread Mark Kimpel
I am using grep to locate colnames to automate a report build and have run into a problem when a colname is not found. The use of integer(0) in a conditional statement seems to be a no no as it has length 0. Below is a self-contained trivial example. I would like to get something like "NA" or -1 fo