Description Usage Arguments Value Examples
Same as prop.table
except that it returns percentages rather than proportions.
1 | percTable(x, margin = NULL, digits = 1, addMargins = !is.na(ncol(x)))
|
x |
A frequency table likely constructed with |
margin |
A numeric representing an index, or vector of indices, to generate the margin for – |
digits |
A numeric indicating the number of decimals to round the percentages to. |
addMargins |
A logical indicating whether marginal totals should be appended to the table or not. If |
Same type as x
except with percentages of a margin rather than frequencies.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | d <- data.frame(Aye=sample(c("Yes","Si","Oui"),177,replace=TRUE),
Bee=sample(c("Hum","Buzz"),177,replace=TRUE))
## 1-D
( A1 <- table(d$Aye) )
prop.table(A1)
percTable(A1)
percTable(A1,digits=3)
percTable(A1,addMargins=TRUE)
( A2 <- xtabs(~Aye,data=d) )
percTable(A2)
## 2-D
( AB1 <- table(d$Aye,d$Bee) )
percTable(AB1,margin=1)
percTable(AB1,margin=2)
percTable(AB1)
percTable(AB1,digits=3)
percTable(AB1,addMargins=FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.