Description Usage Arguments Value Note See Also Examples
Used to put marginal values on the two-way table or array. For tables or arrays with more dimensions see addmargins()
. This version is designed for use in introductory classes where the margin=
argument has been modified to be more intuitive to students. Specifically, This function is a pass-through to addmargins()
with the exception that margin=1
adds a marginal value at the end of the rows and margin=2
adds a marginal value at the end of the columns. The numeric values in margin=
are opposite of what is used in addmargins()
.
1 | addMargins(A, margin = seq_along(dim(A)), ...)
|
A |
table or array |
margin |
A numeric value over which to form margins (see details) |
... |
Additional arguments to be sent to |
A table or array with the same number of dimensions as A
, but with extra levels of the dimensions mentioned in margin
.
This is primarily a wrapper function for addmargins
in stats.
table
, addmargins
, and percTable
in NCStats.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | Aye <- sample(c("Yes", "Si", "Oui"), 177, replace = TRUE)
( A1 <- table(Aye) )
Bee <- sample(c("Hum", "Buzz"), 177, replace = TRUE)
( A2 <- table(Aye, Bee) )
## 1-D table
# Add sums to margin
addMargins(A1)
# Add sums to margin of proportions table
addMargins(prop.table(A1))
## 2-D table
# Add sums to all margins
addMargins(A2)
# Add sums to end of rows (row totals)
addMargins(A2,margin=1)
# Add sums to end of columns (column totals)
addMargins(A2,margin=2)
# Add sums to end of a row proportions table
A2.row <- prop.table(A2,margin=1)
addMargins(A2.row,margin=1)
# Add sums to end of a column proportions table
A2.col <- prop.table(A2,margin=2)
addMargins(A2.col,margin=2)
# Add sums to all margins of proportions table
A2.tbl <- prop.table(A2)
addMargins(A2.tbl)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.