For tables with one row per identifier and level (for example per patient and cell set), divides the values of one level by those of a reference level of the same identifier, for one or several value columns, and returns one row per identifier and value column.
Usage
PlotDataPairRatio(
data,
id,
key,
numerator,
denominator,
values,
names = values,
pseudocount = 0,
log_base = NULL,
names_to = "variable",
values_to = "ratio"
)Arguments
- data
A data frame.
- id
Identifier columns that pair rows.
- key
Column holding the levels.
- numerator, denominator
Levels of
key.- values
Value columns.
- names
Names for
valuesin the output; defaultvalues.- pseudocount
Added to both values.
- log_base
Optional logarithm base.
- names_to, values_to
Names of the output columns.
Value
A data frame with id, names_to, values_to and the two input
values (numerator_value, denominator_value). Identifiers lacking a
level give NA.
See also
Other plot-data builders:
PlotDataBindRows(),
PlotDataConstant(),
PlotDataCount(),
PlotDataCrossShares(),
PlotDataDirection(),
PlotDataDominant(),
PlotDataFromArrays(),
PlotDataJoin(),
PlotDataKeyColours(),
PlotDataLabels(),
PlotDataLonger(),
PlotDataMembership(),
PlotDataProduct(),
PlotDataQuantiles(),
PlotDataRankRows(),
PlotDataRatio(),
PlotDataRecode(),
PlotDataRelative(),
PlotDataSelect(),
PlotDataShares(),
PlotDataSummarise(),
PlotDataUnite()
Examples
d <- data.frame(id = rep(c("p1", "p2"), each = 2), set = c("x", "ref", "x", "ref"),
v = c(4, 2, 1, 2))
PlotDataPairRatio(d, "id", "set", "x", "ref", "v", log_base = 2)
#> id variable ratio numerator_value denominator_value
#> 1 p1 v 1 4 2
#> 2 p2 v -1 1 2