Re: [R] Using a function to consolidate variables

2010-03-18 Thread Phil Spector
David - I think what you're looking for is something like this: mydat = data.frame(a=c(1,2,3),b=c(5,1,4)) consolidate.fun = function(data,var1,var2,saved.max){ +data$saved.max = apply(data[,c(var1,var2)],1,max) +data[,var1] = NULL +data[,var2] = NULL +data + } mydat = consol

[R] Using a function to consolidate variables

2010-03-18 Thread David Young
Dear List, I'm getting the error: object of type 'closure' is not subsettable And am not sure how to get around the problem. I've included two short code sets below. One that shows what I want to do and works, but without using the function much, and another that tries to use the function but ca