From b.rowlingson at lancaster.ac.uk  Tue Aug 13 11:27:57 2013
From: b.rowlingson at lancaster.ac.uk (Barry Rowlingson)
Date: Tue, 13 Aug 2013 10:27:57 +0100
Subject: [Rd] Multiple return values / bug in rpart?
In-Reply-To: <cff453a96347419fa1d1333cbf2c6090@EX-0-HT0.lancs.local>
References: <cff453a96347419fa1d1333cbf2c6090@EX-0-HT0.lancs.local>
Message-ID: <CANVKczMLpt4hj=oGpxE1KVov3ftUkg2F7nJNCXr31ogby-XChA@mail.gmail.com>

On Mon, Aug 12, 2013 at 6:06 PM, Justin Talbot <justintalbot at gmail.com> wrote:
> In the recommended package rpart (version 4.1-1), the file rpartpl.R
> contains the following line:
>
> return(x = x[!erase], y = y[!erase])
>
> AFAIK, returning multiple values like this is not valid R. Is that
> correct? I can't seem to make it work in my own code.

 Works for me, returning a list:

 > foo
function(x){return(x,x*2)}
 > foo(99)
[[1]]
[1] 99

[[2]]
[1] 198

But hey, that might just be because I redefined 'return' earlier:

 > return
function(...){list(...)}

It is unlikely this is the case in rpart though...



[Rd] Multiple return values / bug in rpart?
Barry Rowlingson