| mfv | R Documentation |
S3 methods for the most frequent value (statistical mode) of a fdt.
Useful to estimate the most frequent value (statistical mode). It may also be used with a previous fdt when the original data vector is not known.
## 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, ...)
x |
for |
... |
further arguments (required by the generic). |
mfv.fdt and mfv.fdt_cat calculate the most frequent value (mfv) based on a known formula.
mfv.fdt.multiple and mfv.fdt_cat.multiple call mfv.fdt
or mfv.fdt_cat, respectively, for each variable, that is, each column of the data.frame.
mfv.default returns a vector containing the mfv value(s) of x.
In multimodal cases, this vector has length greater than one.
mfv.fdt returns a numeric vector containing the mfv value(s) of the fdt.
In multimodal cases, this vector has length greater than one.
mfv.fdt.multiple returns a list, where each element is a numeric vector
containing the mfv value(s) of the fdt for each variable.
mfv.fdt_cat returns a character vector containing the mfv value(s) of the fdt_cat.
mfv.fdt_cat.multiple returns a list, where each element is a character vector
containing the mfv value(s) of the fdt_cat for each variable.
Faria, J. C.
Allaman, I. B
Jelihovschi, E. G.
mean.fdt, median.fdt, quantile.fdt.
library(fdth)
## Numerical (multimodal examples)
vx <- c(rep(3,
5),
rep(5,
5),
sample(6:10,
5))
vx
mfv(vx) # Two modes: 3 and 5
tb <- fdt(vx)
tb
mfv(tb) # Mode estimated from grouped data (two modal classes)
vy <- c(rep(3,
5),
sample(6:9,
10,
rep=TRUE),
rep(10,
5))
vy
tb2 <- fdt(vy,
start=3,
end=11,
h=1)
tb2
mfv(tb2) # Two modes in non-adjacent classes
vz <- c(rep(1.2,
6),
rep(6.4,
6),
rep(3.3,
2),
rep(4.7,
2))
vz
tb3 <- fdt(vz,
start=0,
end=8,
h=1)
tb3
mfv(tb3) # Two modes in non-adjacent classes (deterministic example)
## 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 grouped data in a fdt object
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.