proportions {base} | R Documentation |

## Express Table Entries as Fraction of Marginal Table

### Description

Returns conditional proportions given `margins`

, i.e.,
entries of `x`

, divided by the appropriate marginal sums.

### Usage

```
proportions(x, margin = NULL)
prop.table(x, margin = NULL)
```

### Arguments

`x` |
an array, usually a |

`margin` |
a vector giving the margins to split by.
E.g., for a matrix |

### Value

A table or array like `x`

, expressed relative to `margin`

.

### Note

`prop.table`

is an earlier name, retained for back-compatibility.

### Author(s)

Peter Dalgaard

### See Also

`apply`

and `sweep`

are more general
mechanisms for sweeping out marginal statistics.

### Examples

```
m <- matrix(1:4, 2)
m
proportions(m, 1)
DF <- as.data.frame(UCBAdmissions)
tbl <- xtabs(Freq ~ Gender + Admit, DF)
tbl
proportions(tbl, "Gender")
```

[Package

*base*version 4.4.0 Index]