consensus_df: Consensus for data frame

Description Usage Arguments Details Value Examples

Description

Compute the consensus for all items of a data frame, based on Tastle & Wiermann, (2006).

Usage

1
2
consensus_df(data, range = NULL, consensus.only = FALSE, round = 2,
  check.int = TRUE)

Arguments

range

The range of the items indicating the valid values. Default is NULL.

consensus.only

Logical, if only the consensus should be reported. Default is to FALSE.

round

The number of digits to round the result to. Default is to 2.

check.int

Whether the function should check for integers. Default is to TRUE. Only integers are allowd. If FALSE, things can go horribly wrong.

item

The dataframe with the items, for which the conensus should be computed.

Details

n

The number of valid answers on that item

min

The minimum answer on that item

max

The maximum answer on that item

consensus

The consensus

dissensus

The dissensus

n_missing

The absolute number of missing values on that item, defined as NA

perc_missing

The relative number of missing values on that item, defined as NA

Value

Returns an data frame with the consensus and additional information for each item. See details for further explanation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
n = 10 # (max = 26 for now)
var_names <- paste0("var_", letters[1:10])
entries <- matrix(sample(-2:2, n*10, replace = TRUE),
                 nrow = n, ncol = 10)
entries[sample(1:100, 15)] <- NA
data <- as.data.frame(entries)
colnames(data) <- var_names
subj_id <- paste0("id_", sample(letters, n, replace = FALSE))
data <- cbind(subj_id, data, stringsAsFactors = FALSE)
data["var_j"] <- data["var_j"] / 2.3
consensus_df(data, range = c(-2, 2), check.int = TRUE)

kthorstmann/consr documentation built on May 20, 2019, 7:04 p.m.