decision_modus is a function that can be used to find the most frequent (modus) decision. The classes can be defined by the user (e.g., a", "n", "y" -> "ambiguous", "negative", "positive"). This function is useful if large collections of varying decision (e.g., "a", "a", "a", "n", "n") need to be condensed to a single decision (3 x "a", 2 x "n" -> "a").

decision_modus(data, variables = c("a", "n", "y"), max_freq = TRUE)

Arguments

data

is a table containing the classes.

variables

is the class to look for.

max_freq

is a logical parameter (default == TRUE) delivers either the most occurring class or a summary.

Examples

# First example # Enter a string of arbritary of "a","a","y","n" # Result: # [1] a # Levels: a b n y decision_modus(c("a","a","y","n","b"))
#> [1] a #> Levels: a b n y
# Second example # Analyze data from the decision_res_testdat.csv data file filename <- system.file("decision_res_testdat.csv", package = "PCRedux") my_data <- read.csv(filename) head(my_data)
#> testdat test.result.1 test.result.2 test.result.3 conformity #> 1 F1.1 y y y TRUE #> 2 F1.2 y y y TRUE #> 3 F1.3 n n n TRUE #> 4 F1.4 n n n TRUE #> 5 F2.1 y y y TRUE #> 6 F2.2 y y y TRUE
dec <- unlist(lapply(1L:nrow(my_data), function(i) { decision_modus(my_data[i, 2:4]) })) names(dec) <- my_data[, 1] dec
#> F1.1 F1.2 F1.3 F1.4 F2.1 F2.2 F2.3 F2.4 F3.1 F3.2 F3.3 F3.4 F4.1 F4.2 F4.3 F4.4 #> y y n n y y n n y y n n y y n n #> F5.1 F5.2 F5.3 F5.4 F6.1 F6.2 F6.3 F6.4 #> y y n n y y n n #> Levels: y n