Description Usage Arguments Details Value Author(s) Examples
Gives basic statistics for a data item da (ignores NAs), within different levels id.
WARNING - If data is very large, function can encounter serious rounding issues!
1 | strat_stats(id, da, quantiles = NULL)
|
id |
vector of any type (except factor) to describe the various levels, with same length as da. |
da |
numeric vector of data. |
quantiles |
numeric. Between 0 and 1 to determine 0% - 100% quantile for each id. |
Returned data frame contains the following:
level identifier.
number of items in level.
minimum value of da in level.
maximum value of da in level.
sum of values of da in level.
mean value of da in level.
median value of da in level.
standard deviation value of da in level.
specified quantiles of levels.
A data frame with a row for each level (see Details).
Aaron Hayman
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Want to compare weights of different animals from the following data frame:
# ANIMAL WEIGHT
# Chicken 3.0
# Cat 4.2
# Cat 3.1
# Dog 12.8
# Cat 6.1
# Dog 20.4
# Cat 2.3
id = c("Chicken", "Cat", "Cat", "Dog", "Cat", "Dog", "Cat")
da = c(3.0, 4.2, 3.1, 12.8, 6.1, 20.4, 2.3)
strat_stats(id,da)
# id n min max sum mean median SD
# 1 Cat 4 2.3 6.1 15.7 3.925 3.65 1.645955
# 2 Chicken 1 3.0 3.0 3.0 3.000 3.00 NaN
# 3 Dog 2 12.8 20.4 33.2 16.600 16.60 5.374012
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.