Hi, In addition to ?ave(), You could also use ?tapply() or ?aggregate() if this is what you meant.
Lines<-"Charge Strobe [1] Charge FC [2] Charge SG [3] Carcass FC [1] Carcass Strobe [2] Carcass SG [3] Chart Strobe [1] Chart FC [2] Chart SG [3] Boy Strobe [1] Boy FC [2] Boy SG [3] Wires Strobe [1] Wires SG [2] Wires FC [3]" Lines1<-readLines(textConnection(Lines)) Lines2<-gsub("[][]","",Lines1) Lines2<-Lines2[Lines2!=""] votes<-read.table(text=Lines2,header=FALSE,stringsAsFactors=FALSE,col.names=c("Object","Method","Vote")) votes$Rank<-as.numeric(votes$Vote) tapply(votes$Vote,list(votes$Vote,votes$Method),FUN=length) # FC SG Strobe #1 1 NA 4 #2 3 1 1 #3 1 4 NA A.K. ----- Original Message ----- From: Vladimir eremeev <wl2...@gmail.com> To: r-help@r-project.org Cc: Sent: Thursday, December 6, 2012 2:31 AM Subject: Re: [R] What is "print print print" ? Yes, now I see. It's ridiculous that I haven't noticed this elementary error, which I know of for over 10 years. :) Now my problem, it's another question. Here is the code and data, as requested. Sample data, I've copied a part of text file: Charge Strobe [1] Charge FC [2] Charge SG [3] Carcass FC [1] Carcass Strobe [2] Carcass SG [3] Chart Strobe [1] Chart FC [2] Chart SG [3] Boy Strobe [1] Boy FC [2] Boy SG [3] Wires Strobe [1] Wires SG [2] Wires FC [3] Now I read them and make last column numeric: votes<-read.table("comparison.txt", col.names=c("Object", "Method", "Vote")) votes$Rank <- as.numeric(votes$Vote) Now I want to see for each method how many it has first, second and last places: for(m in levels(votes$Metod)) { print(c(m, hist(votes[with(votes, Method == m), "Rank"], breaks=0:3, plot=FALSE)$counts)) } Oups... And now I've found my error, thanks to Opera's spell checker. I have missed the letter 'h' in Method. -- Best regards, Vladimir mailto:wl2...@gmail.com ______________________________________________ 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. ______________________________________________ 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.