reconstruct_two {DiscreteDatasets} | R Documentation |
Reconstruct a set of four-fold tables from rows or columns
Description
In some situations, fourfold tables are reduced to two elements, which makes
it impossible to use them straight away for statistical tests like Fisher's
exact test. But sometimes, when all tables had the same known marginal sums,
the missing values can be restored using that additional information. The
reconstruct_two
function uses a set of such reduced tables, stored
row-wise in a matrix or a data frame, and rebuilds the two missing columns
from automatically computed or given marginal totals.
Usage
reconstruct_two(
dat,
totals = NULL,
insert_at = NULL,
colnames_add = NULL,
colnames_prepend = NULL,
colnames_append = NULL,
colnames_sep = "_"
)
Arguments
dat |
integer matrix or data frame with exactly two
columns; each row represents the first column of a
2x2 matrix for which the other two values are to
be computed and appended to |
totals |
integer vector of exactly one or two values or
|
insert_at |
integer vector of exactly two values between 1 and
4 or |
colnames_add |
character vector of exactly two unique character
strings or |
colnames_prepend |
character vector of exactly two unique character
strings ( |
colnames_append |
character vector of exactly two unique character
strings ( |
colnames_sep |
a single character or |
Value
An integer data frame with four columns.
Examples
data(amnesia)
amnesia_four_columns <- reconstruct_two(
amnesia,
NULL,
NULL,
NULL,
NULL,
c("ThisDrug", "AllOtherDrugs"),
"."
)
head(amnesia_four_columns)
data(hiv)
hiv_four_columns <- reconstruct_two(
hiv,
73,
NULL,
NULL,
NULL,
c("Mutation", "NoMutation"),
"."
)
head(hiv_four_columns)
data(listerdata)
listerdata_four_columns <- reconstruct_two(
listerdata,
c(34244, 39342),
NULL,
NULL,
NULL,
c("This_Cyto", "All_Other_Cytos"),
"_"
)
head(listerdata_four_columns)