[R] Calculating proportions from a data frame rather than a table

Farrel Buchinsky fjbuch at gmail.com
Thu Oct 4 01:28:02 CEST 2007


Incidentally, the feature becomes really powerful when one uses
functions such as addmargins together with prop.table as in

coinf.table <-as.matrix(coinfection)
prop.table(coinf.table,1) # to see proportions from each HPV type per study
addmargins(coinf.table)# to  see totals within study and accross all studies
prop.table(addmargins(coinf.table,1),1)# to see proportions for all
studies added together


On 10/3/07, Farrel Buchinsky <fjbuch at gmail.com> wrote:
> Genius! Thank you very much.
> Yes indeed I should have thought of that. For some reason I have a
> mental blank about the use of row.names and instead I repeatedly put
> that kind of data as a column in the data frame. Thank you for the
> rescue.
>


-- 
Farrel Buchinsky
GrandCentral Tel: (412) 567-7870



More information about the R-help mailing list