Re: [R] R 3.1.2 using a custom function in aggregate() function on Windows 7 OS 64bit

2015-03-05 Thread Bert Gunter
Well, I obviously don't use it either, as I'm just quoting the docs. I either use by(), or tapply(). -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Stoll On Thu,

Re: [R] R 3.1.2 using a custom function in aggregate() function on Windows 7 OS 64bit

2015-03-05 Thread Jeff Newmiller
Bert: using the sample data frame from below, try to interpret the output of this: aggregate( dat[,1:2], dat[,"g",drop=FALSE, FUN=function(x){print(x);class(x)}) The help text you quote is probably not as clear as it should be. Would the following be better? "... and FUN is applied to each col

Re: [R] R 3.1.2 using a custom function in aggregate() function on Windows 7 OS 64bit

2015-03-05 Thread David Winsemius
On Mar 4, 2015, at 2:02 PM, Typhenn Brichieri-Colombi via R-help wrote: > Hello, > > I am trying to use the following custom function in an aggregatefunction, but > cannot get R to recognize my data. I’ve read the help on function()and on > aggregate() but am unable to solve my problem. How ca

Re: [R] R 3.1.2 using a custom function in aggregate() function on Windows 7 OS 64bit

2015-03-05 Thread Bert Gunter
That's not what ?aggregate says: "aggregate.data.frame is the data frame method. If x is not a data frame, it is coerced to one, which must have a non-zero number of rows. Then, each of the variables (columns) in x is split into subsets of cases (rows) of identical combinations of the components o

Re: [R] R 3.1.2 using a custom function in aggregate() function on Windows 7 OS 64bit

2015-03-05 Thread Jeff Newmiller
I don't see your point. No matter which version of aggregate you use, FUN is applied to vectors. Those vectors may be columns in a data frame or not, but FUN is always given one vector at a time by aggregate. --- Jeff Newmill

Re: [R] R 3.1.2 using a custom function in aggregate() function on Windows 7 OS 64bit

2015-03-05 Thread Bert Gunter
Sorry, Jeff. aggregate() is generic. >From ?aggregate: "## S3 method for class 'data.frame' aggregate(x, by, FUN, ..., simplify = TRUE)" Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainl

Re: [R] R 3.1.2 using a custom function in aggregate() function on Windows 7 OS 64bit

2015-03-05 Thread Jeff Newmiller
The aggregate function applies FUN to vectors, not data frames. For example, the default "mean" function accepts a vector such as a column in a data frame and returns a scalar (well, a vector of length 1). Aggregate then calls this function once for each piece of the column(s) you give it. Your

Re: [R] R 3.1.2 using a custom function in aggregate() function on Windows 7 OS 64bit

2015-03-04 Thread Bert Gunter
What do you think dat$a is? I recommend that you spend some time with an R tutorial if you plan to use R. Your code is pretty bad. Examples: use of the ifelse construction instead of if ... else; return() Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not i

[R] R 3.1.2 using a custom function in aggregate() function on Windows 7 OS 64bit

2015-03-04 Thread Typhenn Brichieri-Colombi via R-help
Hello, I am trying to use the following custom function in an aggregatefunction, but cannot get R to recognize my data. I’ve read the help on function()and on aggregate() but am unable to solve my problem. How can I get R torecognize the data inputs for the custom function nested within aggrega