[R] error using lapply with oneway_test (coin package)

2009-05-07 Thread Matthieu Dubois
Dear expeRts, I would like to use a oneway_test (from package coin) to test whether two groups differ on various variables. The variables are encoded within a data frame. Unfortunately, I obtained an error, that I don't understand. Could you please help me ? Example: library(coin) y -

Re: [R] error using lapply with oneway_test (coin package)

2009-05-07 Thread Duncan Murdoch
On 07/05/2009 6:11 AM, Matthieu Dubois wrote: Dear expeRts, I would like to use a oneway_test (from package coin) to test whether two groups differ on various variables. The variables are encoded within a data frame. Unfortunately, I obtained an error, that I don't understand. Could you

Re: [R] error using lapply with oneway_test (coin package)

2009-05-07 Thread Torsten Hothorn
That's a scoping problem, I think a bug in oneway_test. Because the formula var ~ group is created with the anonymous function within lapply, its environment should be the evaluation frame of that function call and var should be visible. If I replace oneway_test() with lm() it works. I

Re: [R] Error with lapply [addirional clarification needed]

2008-11-22 Thread megh
I need one more clarification here : Here I did : fn - function(i) return(list(i, i^2)) ss = sapply(1:4, fn) Here the object ss should be a matrix object : is.matrix(ss) However I feel it lacks some the matrix object properties. For example the syntax min(ss[1,]) generates an error : Error in

Re: [R] Error with lapply [addirional clarification needed]

2008-11-22 Thread Peter Dalgaard
megh wrote: I need one more clarification here : Here I did : fn - function(i) return(list(i, i^2)) ss = sapply(1:4, fn) Here the object ss should be a matrix object : is.matrix(ss) However I feel it lacks some the matrix object properties. For example the syntax min(ss[1,]) generates an

Re: [R] Error with lapply [addirional clarification needed]

2008-11-22 Thread Gabor Grothendieck
Try str(ss) to see what it really looks like. You probably want: fn - function(i) c(i, i^2) On Sat, Nov 22, 2008 at 4:54 AM, megh [EMAIL PROTECTED] wrote: I need one more clarification here : Here I did : fn - function(i) return(list(i, i^2)) ss = sapply(1:4, fn) Here the object ss

[R] Error with lapply

2008-11-20 Thread megh
I have written following codes, with intention to get a list with values 1,2,9,16 : fn - function(i) return(i^2) lapply(1:4, fn, i) However I got following error : Error in FUN(1:4[[1L]], ...) : unused argument(s) (1) Can anyone please tell me what will be the correct code here? Regards, --

Re: [R] Error with lapply

2008-11-20 Thread baptiste auguie
Hi, you are feeding lapply i as an optional argument, which is passed to fn() and causes an error. Just use lapply(1:4, fn), or better yet, sapply, fn - function(i) return(i^2) sapply(1:4, fn) [1] 1 4 9 16 Hope this helps, baptiste On 20 Nov 2008, at 16:31, megh wrote: I have

Re: [R] Error with lapply

2008-11-20 Thread Marc Schwartz
on 11/20/2008 10:31 AM megh wrote: I have written following codes, with intention to get a list with values 1,2,9,16 : fn - function(i) return(i^2) lapply(1:4, fn, i) However I got following error : Error in FUN(1:4[[1L]], ...) : unused argument(s) (1) Can anyone please tell me what

Re: [R] Error with lapply

2008-11-20 Thread Gabor Grothendieck
lapply already passes the first arg to fn and by specifying the i (which is undefined -- its only defined within fn) it would be trying to to pass a second arg to fn yet fn takes only takes one arg. Try these: lapply(1:4, fn) lapply(1:4, ^, 2) On Thu, Nov 20, 2008 at 11:31 AM, megh [EMAIL

Re: [R] Error with lapply

2008-11-20 Thread Bert Gunter
] On Behalf Of Marc Schwartz Sent: Thursday, November 20, 2008 8:50 AM To: megh Cc: r-help@r-project.org Subject: Re: [R] Error with lapply on 11/20/2008 10:31 AM megh wrote: I have written following codes, with intention to get a list with values 1,2,9,16 : fn - function(i) return(i^2) lapply

[R] error in lapply

2008-11-02 Thread Chibisi Chima-Okereke
Dear all, I am getting a error while using lapply to generate plots. The variable .name is used to identify each plot in the main variable. The method worked once but afterwards seems to throw up an error when used in a different case. The input ... dataOut - lapply(names(dataIn), FUN =

[R] error in lapply (sorry error in last e-mail)

2008-11-02 Thread Chibisi Chima-Okereke
Dear all, I am getting a error while using lapply to generate plots. The variable .name is used to identify each plot in the main variable. The method worked once but afterwards seems to throw up an error when used in a different case. The input ... dataOut - lapply(names(dataIn), FUN =