Description Usage Arguments Details Examples
Calculates a proportion from a vector or data frame/matrix.
1 2 3 4 5 6 7 8 9 | proportion(x, ...)
prop_tapply(x, ...)
## Default S3 method:
prop_tapply(x, ...)
## S3 method for class 'data.frame'
prop_tapply(x, col, ...)
|
x |
A data.frame or a vector. |
... |
Additional arguments to be passed to methods. |
tapply(x, x, length) / length(x) can be speedier for smaller data sets and groups but slows down with more data or a greater number of groups.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | proportion(iris, "Species")
proportion(iris$Species)
## Not run:
tapply = prop_tapply(iris, "Sepal.Length"),
proportion = proportion(iris, "Sepal.Length"),
times = 100
)
x <- dplyr::sample_n(iris, 1e6, TRUE)
microbenchmark::microbenchmark(
tapply = prop_tapply(x, "Sepal.Length"),
proportion = proportion(x, "Sepal.Length"),
times = 10
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.