Turns a subjects-by-raters matrix of ratings into the subjects-by-categories
counts used by agreement_counts(). Missing ratings are not counted, so a
subject's row total is the number of raters who rated it. This discards
rater identity: the raters become exchangeable.
Arguments
- x
A subjects-by-raters matrix or data frame of category labels (integer codes, characters, or factors).
NA(and, for numeric input, any non-finite value) marks a missing rating.- categories
Optional vector of all categories, in column order. Unused categories become all-zero columns. Defaults to the shared factor levels, or else the sorted observed labels. Pass it for text ratings that have an order, since the column order sets the linear and quadratic weights in
agreement_counts().
Value
An integer subjects-by-categories matrix whose columns are named by
categories and whose row names are carried over from x. Suitable as
the x argument of agreement_counts().
Examples
counts <- ratings_to_counts(dat.gwet2014)
head(counts)
#> 0 1 2 3
#> [1,] 0 2 2 0
#> [2,] 1 3 0 0
#> [3,] 0 0 1 3
#> [4,] 3 0 0 0
#> [5,] 4 0 0 0
#> [6,] 4 0 0 0
agreement_counts(counts)
#> misskappa: estimator = pairwise, weight = nominal, n = 20
#> estimate se lower upper
#> Fleiss 0.4769 0.0942 0.2922 0.6616
#> Brennan-Prediger 0.5004 0.0962 0.3118 0.6890
