[R] lapply not reading arguments from the correct environment

2007-05-18 Thread jiho
Hello, I am facing a problem with lapply which I think''' may be a bug. This is the most basic function in which I can reproduce it: myfun - function() { foo = data.frame(1:10,10:1) foos = list(foo) fooCollumn=2 cFoo = lapply(foos,subset,select=fooCollumn)

Re: [R] lapply not reading arguments from the correct environment

2007-05-18 Thread Dimitris Rizopoulos
/~m0390867/dimitris.htm - Original Message - From: jiho [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, May 18, 2007 4:41 PM Subject: [R] lapply not reading arguments from the correct environment Hello, I am facing a problem with lapply which I think''' may be a bug

Re: [R] lapply not reading arguments from the correct environment

2007-05-18 Thread Thomas Lumley
On Fri, 18 May 2007, jiho wrote: Hello, I am facing a problem with lapply which I think''' may be a bug. This is the most basic function in which I can reproduce it: myfun - function() { foo = data.frame(1:10,10:1) foos = list(foo) fooCollumn=2 cFoo =

Re: [R] lapply not reading arguments from the correct environment

2007-05-18 Thread jiho
On 2007-May-18 , at 17:09 , Thomas Lumley wrote: On Fri, 18 May 2007, jiho wrote: I am facing a problem with lapply which I think''' may be a bug. This is the most basic function in which I can reproduce it: myfun - function() { foo = data.frame(1:10,10:1) foos = list(foo)

Re: [R] lapply not reading arguments from the correct environment

2007-05-18 Thread Prof Brian Ripley
You need to study carefully what the semantics of 'subset' are. The function body of myfun is not in the evaluation environment. (The issue is 'subset', not 'lapply': select is an *expression* and not a value.) Hint: using subset() programmatically is almost always a mistake. R's subsetting

Re: [R] lapply not reading arguments from the correct environment

2007-05-18 Thread Gabor Grothendieck
In particular, we can use [ directly instead of subset. This is the same as your function except for the line marked ### : myfun2 - function() { foo = data.frame(1:10,10:1) foos = list(foo) fooCollumn=2 cFoo = lapply(foos, [, fooCollumn) ### return(cFoo) }

Re: [R] lapply not reading arguments from the correct environment

2007-05-18 Thread jiho
On 2007-May-18 , at 18:21 , Gabor Grothendieck wrote: In particular, we can use [ directly instead of subset. This is the same as your function except for the line marked ### : myfun2 - function() { foo = data.frame(1:10,10:1) foos = list(foo) fooCollumn=2 cFoo =

Re: [R] lapply not reading arguments from the correct environment

2007-05-18 Thread Gabor Grothendieck
On 5/18/07, jiho [EMAIL PROTECTED] wrote: On 2007-May-18 , at 18:21 , Gabor Grothendieck wrote: In particular, we can use [ directly instead of subset. This is the same as your function except for the line marked ### : myfun2 - function() { foo = data.frame(1:10,10:1)