Description Usage Arguments Details Value See Also Examples
A summaryFunction
, intended to be called from
summarize
, which returns the central value of a variable.
For numeric and integer variables, this is the median. For
character, factor, (have_)labelled, Date and logical variables, the central value is the mode
(i.e. the value that occurs the largest number of times).
1 | centralValue(v, ...)
|
v |
A variable (vector). |
... |
Extra arguments to be passed to class-specific functions. These incluse
|
Note that NA, NaN and Inf values are ignored for numeric and integer variables, while only NA values are ignored for factor, character, Date and (haven_)labelled variables. No values are ignored for logical variables.
An object of class summaryResult
with the following entries: $feature
(the mode/median),$result
(the central value of v
) and $value
(identical
to $result
).
If the mode is returned and it is not uniquely determined, the first value qualifying as a mode is
returned, when the variable is sorted according to sort
.
summaryFunction
, summarize
, summaryResult
,
allSummaryFunctions
1 2 3 4 5 | #central value of an integer variable:
centralValue(c(rep(1, 25), rep(2, 10), rep(3, 20)))
#central value of a character variable:
centralValue(as.character(c(rep(1, 20), rep(2, 10), rep(3, 20))))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.