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)
/~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
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 =
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)
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
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)
}
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 =
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)