Description Usage Arguments Value See Also Examples
Summarize a vector/variable into a single number, either a mean (median) for numeric vectors or the mode for categorical (character, factor, ordered, or logical) vectors. Useful for aggregation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | mean_or_mode(x)
## Default S3 method:
mean_or_mode(x)
## S3 method for class 'numeric'
mean_or_mode(x)
## S3 method for class 'data.frame'
mean_or_mode(x)
median_or_mode(x)
## Default S3 method:
median_or_mode(x)
## S3 method for class 'numeric'
median_or_mode(x)
## S3 method for class 'data.frame'
median_or_mode(x)
|
x |
A vector. |
A numeric or factor vector of length 1.
prediction
, build_datalist
, seq_range
1 2 3 4 5 6 7 8 | require("datasets")
# mean for numerics
mean_or_mode(iris)
mean_or_mode(iris[["Sepal.Length"]])
mean_or_mode(iris[["Species"]])
# median for numerics
median_or_mode(iris)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.