[R] count by value

Jim Lemon jim at bitwrit.com.au
Wed Apr 10 09:03:59 CEST 2013

On 04/10/2013 04:45 AM, catalin roibu wrote:
> Hello all!
> I have a big problem now. I want a data frame like this:
> dput(head(test,100))
 > ...
> Now I want to group rownames (in this case year) in 10 years classes and I
> want to count for each 10 years classe (decade) the number of major and
> minor events.
> I try this code to group values in classes but don't work and I don't know
> how to count a  value for each row and sum them for each 10 years classes.
> test$year<-as.numeric(row.names(test))
> q<-cut(rownames(test),seq(0,ceiling(max(rownames(test)+10),by=10),
> labels=seq(10,ceiling(max(rownames(test)+10), by=10))))
> Please help me to solve this problem!

Hi catalin,
I could only get about half of your data to read into R (I think it is 
due to a limitation on the number of characters that can be read in one 
command) but I think what you want is this (data frame is "crdat"):

for(groupstart in seq(1,100,by=10))


More information about the R-help mailing list