[R] Looking for a quick way to combine rows in a matrix

Johannes Hüsing johannes at huesing.name
Tue May 12 19:27:30 CEST 2009


jim holtman schrieb:
> Try this:
>
>   
>> key <- rownames(a)
>> key[key == "AT"] <- "TA"
>> do.call(rbind, by(a, key, colSums))
>>     
something like

paste(sort(strsplit(key, split="")[[1]]), "")

might be more general.




More information about the R-help mailing list