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))
 print(table(crdat[groupstart:(groupstart+9),]))

Jim

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to