proportions(x, margin = NULL) prop.table(x, margin = NULL)
| x | a numeric matrix, a table, or an array. |
| margin |
a vector of integers or character strings over which the margins are specified.
For example, if x is a matrix, margin=1 indicates rows
and margin=2 indicates columns.
If character strings, they are expected to be a subset of names(dimnames(x)).
Note that margin specifies the dimensions by which the entries of x are scaled in the result. If margin is NULL, all entries in x are scaled by the sum of x. |
x <- array(1:24, dim = c(4, 3, 2),
dimnames = list(A=NULL, B=paste0("b",1:3), C=NULL))
proportions(x, c(2, 3))
proportions(x, c("B", "C"))
proportions(x)