Andras Farkas <motyocska <at> yahoo.com> writes: > > Dear All, > > please help with the following if you can: > [snip details] > > #### > first24 <-sum(unlist(c(subset(df, df[, 'simt'] > 0 & df[, 'simt'] <= > z[1], 3)))) > second24 <-sum(unlist(c(subset(df, df[, 'simt'] > z[1] & df[, 'simt'] <= > z[2], 3)))) > third24 <-sum(unlist(c(subset(df, df[, 'simt'] > z[2] & df[, 'simt'] <= > z[3], 3)))) > fourth24 <-sum(unlist(c(subset(df, df[, 'simt'] > z[3] & df[, 'simt'] <= > z[4], 3)))) > fifth24 <-sum(unlist(c(subset(df, df[, 'simt'] > z[4] & df[, 'simt'] <= z[5], 3)))) > sixth24 <-sum(unlist(c(subset(df, df[, 'simt'] > z[5] & df[, 'simt'] <= > z[6], 3)))) > > last24 <-sum(unlist(c(subset(df, df[, 'simt'] > z[6] , 3)))) > > my end result is to get this vector: > > c(first24,second24,third24,fourth24,fifth24,sixth24,last24) > > #### >
Some hints: see ?xtabs for weighted tabulations and ?cut for forming categories to tabulate. Try to solve this using just those functions, 'c', and the '~' operator. It can be done in one line. HTH, Chuck ______________________________________________ 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.