Re: [R] add values in one column getting range from other column

2012-10-02 Thread Rui Barradas
Hello, Maybe this time you've got it wrong, Arun. The op wants to sum the areas, not just label them. Using your code, Range=cut(dat1$Percent, breaks=c(-Inf,0, 25, 50, 75, 100), labels=c("<=0", "0-25", "25-50", "50-75", ">75")) aggregate(Area ~ Range, data = dat1, FUN = sum) # Range

Re: [R] add values in one column getting range from other column

2012-10-02 Thread arun
HI, Infact, there is no need for aggregate(). dat1$range<-cut(dat3$Percent,breaks=c(-Inf,0,25,50,75,100),labels=c("<=0","0-25","25-50","50-75",">75"))  dat1 #  Area Percent range #1  456   0   <=0 #2 3400  10  0-25 #3   79  25  0-25 #4   56  18  0-25 #5  467   0   <=0 #6   67  

Re: [R] add values in one column getting range from other column

2012-10-02 Thread arun
Hi, I guess this is what you wanted: dat1<-read.table(text=" Area Percent 456   0 3400  10 79  25 56   18 467 0 67  67 839    85 1120  0 3482  85 ",sep="",header=TRUE)  aggregate(dat1$Percent, list(Area = dat1[,"Area"],Range=cut(dat1  $Pe