# [R] Aggregate

Jim Lemon bitwrit at ozemail.com.au
Tue Nov 7 21:28:41 CET 2000

```OOPS!  This is what I get for reading the R help list at the end of the
day.

I forgot to solve the "sort" problem in the following function:

sum.response.patterns<-function(mat) {
nrows<-dim(mat)[1]
sorted.mat<-mat[order(mat[,1],mat[,2],mat[,3],mat[,4],mat[,5]),]
pattern.count<-rep(1,nrows)
j<-1
for(i in 1:(nrows-1)) {
if(sum(abs(sorted.mat[i,]-sorted.mat[i+1,])) == 0)
pattern.count[j]<-pattern.count[j]+1
else j<-j+1
}
return(pattern.count[1:j])
}

So, this morning I have fooled around trying to get something like I
would expect from an UNIX 'sort' function and, while I have gotten the
argument list as a character string:

paste(paste("mat[,",1:dim(mat)[2],"]",sep="")sep=",",collapse="")

I have drawn a blank on how to make this into an argument list.  Might I
beg assistance?

Jim

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```