View source: R/decision_modus.R
decision_modus | R Documentation |
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)
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. |
gives a factor
(S3 class, type of integer
) as output
for a decision
Stefan Roediger, Michal Burdukiewcz
# 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"))
# 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)
dec <- unlist(lapply(1L:nrow(my_data), function(i) {
decision_modus(my_data[i, 2:4])
}))
names(dec) <- my_data[, 1]
dec
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.