stats::modal
-- the modal (most
frequent) value(s)stats::modal
(data)
returns the most
frequent value(s) of the data.
stats::modal(x1, x2, ..)
stats::modal([x1, x2, ..])
stats::modal(s <, c>)
x1, x2, .. |
- | the statistical data: arithmetical expressions. |
s |
- | a sample of domain type stats::sample . |
c |
- | an integer representing a column index of the sample
s . This column provides the data x1 ,
x2 etc. |
an arithmetical expression.
a sequence consisting of a list and an integer. The list contains
the most frequent element(s) in the data, the integer specifies the
number of occurrences. E.g., the result ``[data5, data10],
21
'' means that data5
and data10
are
the most frequent data items, each occurring 21 times.
stats::a_quantil
,
stats::geometric
,
stats::harmonic
,
stats::mean
, stats::median
, stats::quadratic
, stats::stdev
, stats::variance
c
is optional, if the data are given
by a stats::sample
object containing only one non-string column. Cf. example 3.We calculate the modal value of a data sequence:
>> stats::modal(2, a, b, c, b, 10, 12, 2, b)
[b], 3
Alternatively, the data may be passed as a list:
>> stats::modal([a, a, a, b, c, b, 10, 12, 2, b])
[a, b], 3
We create a sample containing ``age'' and ``gender'':
>> stats::sample([[32, "f"], [25, "m"], [40, "f"], [23, "f"]])
32 "f" 25 "m" 40 "f" 23 "f"
The modal value of the second column (the most frequent ``gender'') is calculated:
>> stats::modal(%, 2)
["f"], 3
We create a sample consisting of only one column:
>> stats::sample([4, 6, 2, 6, 8, 3, 2, 1, 7, 9, 3, 6, 5, 1, 6, 8]):
The modal value of these data is calculated. In this case the column does not have to be specified, since there is only one column:
>> stats::modal(%)
[6], 4