count_spectra.RdSummary statistics of factor variable in a hypecSpec object by ID
count_spectra(
OBJ,
Var = NULL,
ID = "ID",
decimals = 1,
include_na = TRUE,
na_level = "(Missing)",
na.rm = TRUE,
total = FALSE
)hyperSpec object
(string) variable name of factor variable
(string) variable name of ID variable
(integer) number of decimals to round to calculating the percentages. Default is 2.
(logical) If TRUE, NA values are included.
(character) Name for the level, which represents NA value.
(logical) used by function sum(). Default is TRUE.
(logical) Add row with "total".
a data frame with counts and percentages by group and ID
Other count spectra functions:
has_enough_IDs(),
has_too_few_IDs()
count_spectra(Spectra2, "class", ID = "gr")
#> Warning: Function 'chk.hy' is deprecated.
#> Use function 'assert_hyperSpec' instead.
#> Warning: `fct_explicit_na()` was deprecated in forcats 1.0.0.
#> ℹ Please use `fct_na_value_to_level()` instead.
#> ℹ The deprecated feature was likely used in the spHelper package.
#> Please report the issue to the authors.
#> n_ID n_spectra percent_ID percent_spectra
#> K 3 50 25.0% 33.3%
#> l 3 30 25.0% 20.0%
#> N 3 19 25.0% 12.7%
#> S1 3 51 25.0% 34.0%
count_spectra(OBJ = Spectra2, Var = "class", ID = "gr")
#> Warning: Function 'chk.hy' is deprecated.
#> Use function 'assert_hyperSpec' instead.
#> n_ID n_spectra percent_ID percent_spectra
#> K 3 50 25.0% 33.3%
#> l 3 30 25.0% 20.0%
#> N 3 19 25.0% 12.7%
#> S1 3 51 25.0% 34.0%