Description Usage Arguments Details Author(s) See Also Examples
xtab
generates cross tabulation of two variables.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | xtab(
x,
y,
data = NULL,
row.pct = TRUE,
na.rm = FALSE,
rnd = 1,
print.table = TRUE
)
## Default S3 method:
xtab(...)
## S3 method for class 'character'
xtab(
x,
y,
data = NULL,
row.pct = TRUE,
na.rm = FALSE,
rnd = 1,
print.table = TRUE
)
## S3 method for class 'list'
xtab(
x,
y,
data = NULL,
row.pct = TRUE,
na.rm = FALSE,
rnd = 1,
print.table = TRUE
)
## S3 method for class 'data.frame'
xtab(
x,
y,
data = NULL,
row.pct = TRUE,
na.rm = FALSE,
rnd = 1,
print.table = TRUE
)
|
x |
a character, factor or logical object OR list OR data frame |
y |
a character, factor or logical object |
data |
a data frame object (Optional) |
row.pct |
a logical value: if NULL, a default table without any percentages is produced. If TRUE, row percentages are shown and if FALSE, column percentages. |
na.rm |
A logical value to specify missing values, <NA> in the table |
rnd |
specify rounding of numbers. See |
print.table |
logical value to display formatted outputs |
... |
optional arguments |
Exploring data before jumping into complex analysis is always a necessity. The first step of an analysis is always to summarize and display data.
xtab
produce contigency table.
References:
Essential Medical Statistics, Betty R. Kirkwood & Jonathan A.C. Sterne, Second Edition. Chapter 3
An Introduction to MEdical Statistics, Martin Bland, Thrid Edition, Chapter 4
Myo Minn Oo (Email: dr.myominnoo@gmail.com | Website: https://myominnoo.github.io/)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | xtab(education, induced, infert)
xtab(infert$education, infert$induced)
xtab(spontaneous, induced, infert, row.pct = FALSE) # column percentage
xtab(spontaneous, induced, infert, row.pct = NULL) # DO NOT SHOW PERCENTAGE
# multiple variables
xtab(c(spontaneous, case, induced), education, infert)
## Not run:
# variables' labels as footnote
infert.new <- labelVars(infert, c(spontaneous, case, induced),
c("SPONTANEOUS", "CASE YES OR NO", "INDUCED"))
xtab(c(spontaneous, case, induced), education, infert.new)
## End(Not run)
# whole dataset
xtab(infert, case)
xtab(infert, induced)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.