Re: [R] coping with a warning in if()

2010-01-20 Thread Héctor Villalobos
Thanks to all who responded. I've learn a lot from your comments. The best solution I can see is to use both 'missing()' and 'match.arg()' in my function. Héctor > Hi, > > I'm sure this one is very easy > > I am trying to write a function where one of its arguments has two posible > (strin

Re: [R] coping with a warning in if()

2010-01-19 Thread Lyman, Mark
Héctor Villalobos ipn.mx> writes: > > Hi, > > I'm sure this one is very easy > > I am trying to write a function where one of its arguments has two posible > (strings) values, > defaulting to one of them if none is specified. My problem is that when > evaluating the function > the foll

Re: [R] coping with a warning in if()

2010-01-19 Thread Peter Alspach
Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Héctor Villalobos > Sent: Wednesday, 20 January 2010 10:34 a.m. > To: R-help@r-project.org > Subject: [R] coping with a warning in if() > > Hi, > > I'm

Re: [R] coping with a warning in if()

2010-01-19 Thread jim holtman
Look at what happens when you don't pass in 'result': > c('simple', 'complete') %in% c("simple", "s", "complete", "c") [1] TRUE TRUE result is a vector of length two and provides two results and the 'if' was only expecting one. You might have to debug your code some more. You probably want to u

[R] coping with a warning in if()

2010-01-19 Thread Héctor Villalobos
Hi, I'm sure this one is very easy I am trying to write a function where one of its arguments has two posible (strings) values, defaulting to one of them if none is specified. My problem is that when evaluating the function the following warning is produced: "the condition has length > 1