epitable | R Documentation |
Display a cross tabulation of two variables optionally with percentages (global perc or row or col percentages).
Chi Square with associated p.value are calculated. (optionally fisher)
Missing are counted and can optionally be included in the table
If table contain binary variable, then epiorder function is apply on the two variable to get a resulting table compatible with usual epidemiology interpretation. 0/1 variables are transformed into Yes/No and Yes is displayed before No Exposed Cases appear on upper left part of the table.
epitable(
data,
out,
exp,
epiorder = TRUE,
missing = FALSE,
row = FALSE,
col = FALSE,
perc = FALSE,
fisher = TRUE,
total = TRUE
)
data |
The dataframe to be analysed |
out |
"Outcome", variable or dataframe column name (character string) representing the outcome. Will be displayed in columns in the cross tabulation. Numeric, factors or text formats are supported. |
exp |
"Exposure" variable or dataframe column name (character string) representing the exposure. Will be displayed in rows in the cross tabulation. Numeric, factors or text formats are supported. Short syntax is available. |
epiorder |
Boolean. Should data be reordered to respect epi tables? Default to TRUE. (i.e., Yes/No) |
missing |
Boolean. If FALSE, missing are not included in the table. A summary output of number of missing values is added at the end |
row |
"Row percentages", boolean. If TRUE, percentages by row are displayed. |
col |
"Col percentages", boolean. If TRUE, percentages by column are displayed. |
perc |
"Table percentages", boolean. If TRUE, percentages by cell are displayed. |
fisher |
Boolean. If TRUE, display the fisher exact probability. Default to TRUE. If the cross tabulation is larger than 2*2, then Fisher is not calculated. |
total |
Boolean. If TRUE, display marginal total. Default to TRUE. |
EPITABLE
An array containing values of
table
: The resulting table
rowperc
: The optional row percentage
colperc
: The optional col percentage
totperc
: The optional percentage
chisq
: Chi Square value
p
: Estimated probability of this distribution
fischer
: Exact probability
missing
: Number of missing values
Gilles Desve
Based on: Epi6 and Stata functionnality, available at https://github.com/.
freq
for frequency distributions
data <- data.frame(id = 1:10,
cases = c(rep(1,3), rep(0,7)),
vacc = sample(c(0,1), replace = TRUE, size = 10))
data[8,2]<-NA
table(data$cases, data$vacc, useNA = "always")
result <- epitable(data,cases,vacc)
result$table
result$missing
result$chisq
result$fisher
epitable(data,cases,vacc,epiorder=FALSE)
epitable(data,"cases","vacc")
epitable(data,out=cases,exp=vacc,missing=TRUE)
epitable(data,out=cases,exp=vacc,row=TRUE)
data <- data.frame(id = 1:10,
cases = c(rep(1,3), rep(0,7)),
vacc = sample(c(0,1,2), replace = TRUE, size = 10))
epitable(data,cases,vacc,perc=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.