[R] SAS to R migration questions

Fernando Henrique Ferraz P. da Rosa mentus at gmx.de
Sun Sep 12 23:24:58 CEST 2004


Fernando Henrique Ferraz P. da Rosa writes:
> cust <- c(111,111,112)
> cc <- data.frame(t(sapply(unique(cust),function(level,vec) {
> c(custid=level,freq=sum(vec==level)) },cust))) 
> cc[order(cc$freq,decreasing=T),]

        An even simpler solution:
 
        cc <- data.frame(table(cust))
        cc[order(cc$Freq,decreasing=T),]


--
Fernando Henrique Ferraz P. da Rosa
http://www.ime.usp.br/~feferraz




More information about the R-help mailing list