Re: [R] create index for tapply or by

2013-06-27 Thread Gerrit Eichner
Hi, Witold, take a look at ?findIntervals It might give want you need. Hth -- Gerrit On Thu, 27 Jun 2013, Witold E Wolski wrote: Is there a build in function to create an index for tapply or by given a a numeric vector x an a vector of breaks? What I want to do is: x <- 1:100 breaks <-

Re: [R] create index for tapply or by

2013-06-27 Thread Rui Barradas
Hello, Try using ?cut y2 <- cut(x, breaks) by(x, y2, sum) Hope this helps, Rui Barradas Em 27-06-2013 09:24, Witold E Wolski escreveu: Is there a build in function to create an index for tapply or by given a a numeric vector x an a vector of breaks? What I want to do is: x <- 1:100 break

[R] create index for tapply or by

2013-06-27 Thread Witold E Wolski
Is there a build in function to create an index for tapply or by given a a numeric vector x an a vector of breaks? What I want to do is: x <- 1:100 breaks <- c(0,10,20,50,99,110) y <- rep(0,length(x)) for(i in 2:length(breaks)){ y[which(x>breaks[i-1] & x <= breaks[i])] <- i } by(x,y,sum) but