Skip to content
Prev 179567 / 398506 Next

error using lapply with oneway_test (coin package)

On 07/05/2009 6:11 AM, Matthieu Dubois wrote:
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 think a workaround is to construct the data argument explicitly, i.e.

lapply(y, function(var) oneway_test(var ~ group, data.frame(var=var, 
group=group)))

I've cc'd Torsten Hothorn, the maintainer of coin.

Duncan Murdoch