Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mfv

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 fdt or fdt_cat (simple or multiple) object.

...

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.multiplecall respectively mfv.fdt or mfv.fdt_catfor 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)

José Cláudio Faria
Enio G. Jelihovschi
Ivan B. Allaman

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

(tb <- fdt(mdf))

mfv(tb)      # From agruped dad in a fdt


## 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

(tb <- fdt_cat(mdf))

mfv(tb)      # From agruped dad in a fdt

fdth

Frequency Distribution Tables, Histograms and Polygons

v1.2-5
GPL (>= 2)
Authors
Jos<e9> Cl<e1>udio Faria, Enio G. Jelihovschi and Ivan B. Allaman
Initial release
2020-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.