Learn R Programming

DanielBiostatistics10th (version 0.2.6)

addProbs: Conditional and/or Marginal Probabilities

Description

Add conditional and/or marginal probabilities to a two-way contingency table.

Usage

addProbs(A, margin = seq_len(nd), fmt = "%d (%.1f%%)")

Value

Function addProbs returns an 'addProbs' object, which inherits from table and noquote.

Arguments

A

matrix of typeof integer, two-dimensional contingency table. See addmargins

margin

integer scalar or vector, see addmargins

fmt

character scalar, C-style string format with a %d and an %f%% for the counts and proportions (order enforced).

Details

Function addProbs provides the joint, marginal (using margin = 1:2) and conditional (using margin = 1L or margin = 2L) probabilities of a two-dimensional contingency table.

See Also

Examples

Run this code
addProbs(table(warpbreaks$tension))

storage.mode(VADeaths) = 'integer'
addProbs(VADeaths)
addProbs(VADeaths, margin = 1L)
rowSums(proportions(VADeaths, margin = 1L))
addmargins(VADeaths, margin = 1L)

Run the code above in your browser using DataLab