[R] contingency tables in R
oohpsjin at gmail.com
Sun Jul 22 18:32:23 CEST 2012
I am interested in creating contingency tables, namely one that would
let me find the frequency and proportion of patients with specific
risk factors (dyslipidemia, diabetes, obesity, smoking, hypertension).
There are 3 dimensions I would like to divide the population into:
sex, family history, and number of risk factors.
In R, I used the following code:
However, when I conduct the following code:
Here the table simply considers the additional risk factors as new
dimensions, which I do not want. I would like to find a way where the
dimensions are sex, family history, and number of risk factors and I
am finding the frequency and prevalence for each risk factor
(dyslipidemia, diabetes, obesity, smoking, hypertension) in each of
The only way to get around this problem I could think of is to create
new data frames for each number of risk factor subgroup: numrisk1,
numrisk2, numrisk3…where numrisk1 indicates population with 1 risk
factor. Then I could calculate the prevalence of each risk factor
separately. This approach will take a very long time so I was hoping
to ask if anyone knew of a solution to this issue I am having with
contingency tables...perhaps a useful R package?
Thank you for your help!
Masters Student (Epidemiology)
More information about the R-help