Skip to contents

Compute the sample mode.

Usage

mfreq(x, na.rm = FALSE, rounding = 2, grouped = TRUE, details = FALSE)

Arguments

x

R object (list) of class leem. Use new_leem() function.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

details

Logical object. Details of data (default FALSE).

Examples

library(leem)
# set.seed(10)
x <- rnorm(36, 100, 50)
set.seed(10)
y <- rbinom(36, 10, 0.8)
w <- rep(letters[1:4], 1:4)
(tab1 <- y |> new_leem(variable = "discrete") |> tabfreq())
#> 
#> Table of frequency 
#> Type of variable: discrete
#> 
#>   Groups Fi   Fr Fac1 Fac2 Fp  Fac1p  Fac2p
#> 1      6  1 0.03    1   36  3   2.78 100.00
#> 2      7  8 0.22    9   35 22  25.00  97.22
#> 3      8 13 0.36   22   27 36  61.11  75.00
#> 4      9 11 0.31   33   14 31  91.67  38.89
#> 5     10  3 0.08   36    3  8 100.00   8.33
#> ============================================== 
#> Groups: Discretized grouping 
#> Fi: Absolute frequency 
#> Fr: Relative frequency 
#> Fac1: Cumulative frequency (below) 
#> Fac2: Cumulative frequency (above) 
#> Fp: Percentage frequency 
#> Fac1p: Cumulative percentage frequency (below) 
#> Fac2p: Cumulative percentage frequency (above) 
#> 
(tab2 <- x |> new_leem(variable = "continuous") |> tabfreq())
#> 
#> Table of frequency 
#> Type of variable: continuous
#> 
#>               Classes Fi     PM   Fr Fac1 Fac2 Fp  Fac1p  Fac2p
#> 1  -16.97 |---  17.29  2   0.16 0.06    2   36  6   5.56 100.00
#> 2   17.29 |---  51.55  6  34.42 0.17    8   34 17  22.22  94.44
#> 3   51.55 |---  85.81  8  68.68 0.22   16   28 22  44.44  77.78
#> 4  85.81 |---  120.07  4 102.94 0.11   20   20 11  55.56  55.56
#> 5 120.07 |---  154.33 12 137.20 0.33   32   16 33  88.89  44.44
#> 6 154.33 |---  188.59  4 171.46 0.11   36    4 11 100.00  11.11
#> 
#> ============================================== 
#> Classes: Grouping of classes 
#> Fi: Absolute frequency 
#> PM: Midpoint 
#> Fr: Relative frequency 
#> Fac1: Cumulative frequency (below) 
#> Fac2: Cumulative frequency (above) 
#> Fp: Percentage frequency 
#> Fac1p: Cumulative percentage frequency (below) 
#> Fac2p: Cumulative percentage frequency (above) 
#> 
(tab3 <- w |> new_leem(variable = "discrete") |> tabfreq())
#> 
#> Table of frequency 
#> Type of variable: discrete
#> 
#>   Groups Fi  Fr Fac1 Fac2 Fp Fac1p Fac2p
#> 1      a  1 0.1    1   10 10    10   100
#> 2      b  2 0.2    3    9 20    30    90
#> 3      c  3 0.3    6    7 30    60    70
#> 4      d  4 0.4   10    4 40   100    40
#> ============================================== 
#> Groups: Discretized grouping 
#> Fi: Absolute frequency 
#> Fr: Relative frequency 
#> Fac1: Cumulative frequency (below) 
#> Fac2: Cumulative frequency (above) 
#> Fp: Percentage frequency 
#> Fac1p: Cumulative percentage frequency (below) 
#> Fac2p: Cumulative percentage frequency (above) 
#> 
y |> new_leem(variable = "discrete") |> tabfreq() |> mfreq()
#> [1] 8
x |> new_leem(variable = "continuous") |> tabfreq() |> mfreq()
#> [1] 137.2
w |> new_leem(variable = "discrete") |> tabfreq() |> mfreq()
#> [1] "d"