mfv {fdth} | R Documentation |
Most frequent value (statistical mode) of frequency distribution table (numerical and categorical variable)
Description
S3 methods for the most frequent value (statistical mode) of a fdt
.
Useful to estimate the most frequent value or statistical mode. May also be used, by using a previous fdt
, when the original data vector is not known.
Usage
## S3 generic
mfv(x, ...)
## S3 methods: numerical and categorical
## Default S3 method:
mfv(x, ...)
## S3 method for class 'fdt'
mfv(x, ...)
## S3 method for class 'fdt.multiple'
mfv(x, ...)
## S3 method for class 'fdt_cat'
mfv(x, ...)
## S3 method for class 'fdt_cat.multiple'
mfv(x, ...)
Arguments
x |
a |
... |
required to be generic. |
Details
mfv.fdt
and mfv.fdt_cat
calculates the most frequent value (mfv) based on a known formula.
mfv.fdt.multiple
and mfv.fdt_cat.multiple
call respectively mfv.fdt
or mfv.fdt_cat
for each variable, that is, each column of the data.frame.
Value
mfv.fdt
returns a numeric vector containing the mfv value of the fdt
.
mean.fdt.multiple
returns a list, where each element is a numeric vector
containing the mean value of the fdt
for each variable.
mfv.fdt_cat
returns a character vector containing the mfv value of the fdt_cat
.
mean.fdt_cat.multiple
returns a list, where each element is a character vector
containing the mfv value of the fdt_cat
for each variable.
Author(s)
Faria, J. C.
Allaman, I. B
Jelihovschi, E. G.
See Also
mean.fdt
, median.fdt
.
Examples
# Numerical
mdf <- data.frame(x=rnorm(1e2,
20,
2),
y=rnorm(1e2,
30,
3),
z=rnorm(1e2,
40,
4))
head(mdf)
mfv(mdf$x) # From vector x
mfv(mdf$y) # From vector y
mfv(mdf$z) # From vector z
(ft <- fdt(mdf))
mfv(ft) # From agruped data in a fdt object
## Categorical
mdf <- data.frame(c1=sample(letters[1:5],
1e3,
rep=TRUE),
c2=sample(letters[6:10],
1e3,
rep=TRUE),
c3=sample(letters[11:21],
1e3,
rep=TRUE),
stringsAsFactors=TRUE)
head(mdf)
mfv(mdf$c1) # From vector c1
mfv(mdf$c2) # From vector c2
mfv(mdf$c3) # From vector c3
(ft <- fdt_cat(mdf))
mfv(ft) # From agruped data in a fdt object