This function can be used to calculate the sum of the tables for each combination of raters. The output table can be used to estimate the agreement statistics between two or more raters. First the crosstable is made for each combination of raters. This results in 2*(m-1) tables, where m is the number of raters. Then these tables are summed to one table.

sumtable(df, ratings = NULL, levels = NULL, offdiag = NULL)

Arguments

df

The input data frame that contains the scores for each rater in each column

ratings

A character vector that contains the names of the factor variables that need to be used as ratings

levels

A character vector that contains the levels of the factors.

offdiag

A logical parameter indicating if the of diagonal means should be used, default is TRUE with more than two raters

Value

Returns a contingency table, an object of class "table", an array of integer values.

Examples

df <- data.frame(r1=factor(c(1,0,1,0,0,1,1,0,0,0,1,1,0,1,1)),
                 r2=factor(c(1,1,1,1,0,1,1,0,0,0,1,1,0,1,0)),
                 r3=factor(c(1,1,1,0,0,0,1,1,1,0,0,1,0,1,1)),
                 r4=factor(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)))
sumtable(df=df, ratings=c("r1", "r2", "r3", "r4"), levels=c("0","1"))
#>    0  1
#> 0 12 27
#> 1  6 45

df <- data.frame(r1=factor(c(1,2,2,0,3,3,1,0,3,0,2,2,0,3,1)),
                 r2=factor(c(1,1,1,0,3,3,1,0,1,0,2,2,0,2,1)),
                 r3=factor(c(1,1,1,3,3,2,1,0,1,0,2,2,0,3,1)),
                 r4=factor(c(1,2,1,0,3,3,1,0,3,0,2,2,0,2,1)))
sumtable(df=df, ratings=c("r1", "r2", "r3", "r4"), levels=c("0","1", "2", "3"))
#>      0    1    2    3
#> 0 21.0  0.0  0.0  1.5
#> 1  0.0 23.0  3.5  2.0
#> 2  0.0  3.5 14.0  3.5
#> 3  1.5  2.0  3.5 11.0