Skip to content
Prev 139309 / 398506 Next

default values

On Wed, 12 Mar 2008, Dwayne Blind wrote:

            
What was the error?  It works for me (so I've no idea), and returns NULL, 
the value of the last expression (invisibly).  I think you intended

f <- function(x, y, z) if (a==0) x[1]+x[2]+y else x[1]+x[2]+y+z

or

f <- function(x, y, z) ifelse(a==0, x[1]+x[2]+y, x[1]+x[2]+y+z)