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. It doesn't appear that rpartpl.R is used anywhere, so this may have never caused an issue. But it's tripping up my R compiler. Thanks, Justin Talbot
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...
I don't remember what rpartpl once did myself; as you point out it is a routine that is no longer used and should be removed. I've cc'd Brian since he maintains the rpart code. Long ago return() with multiple arguments was a legal shorthand for returning a list. This feature was depricated in Splus, I think even before R rose to prominence. I vaguely remember a time when it's usage generated a warning. The fact that I've never noticed this unused routine is somewhat embarrassing. Perhaps I need a "not documented, never called" addition to R CMD check to help me along. Terry Therneau> 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. > > It doesn't appear that rpartpl.R is used anywhere, so this may have > never caused an issue. But it's tripping up my R compiler. > > Thanks, > Justin Talbot