Re: [R] how to use by function

2012-06-19 Thread arun
Hi, Not familiar with by function. But you can get the result : mat[,1]<-(rle(data[,1]))$values mat[1,]<-(rle(data[,1]))$values mat[3,2:3]<-(rle(data[,2])$values)[4:5] > mat [,1] [,2] [,3] [1,]    1    2    3 [2,]    2   NA   NA [3,]    3    2    4 A.K. - Original Message -

Re: [R] how to use by function

2012-06-19 Thread Rui Barradas
Hello, Your code is not working because you are not understanding what's written in the help page for 'by'. 'by' breaks its first argument, a data.frame, (could be matrix) into sets of rows using 'index' to do the breaking. Each set of rows is the argument for FUN, a function that already ex