Convert wide data to the long format

wide_to_long(data)

Arguments

data

Data in a wide format. Must be 2D data object which can be converted to a data.frame

Value

The data converted into long format. A data.frame with three columns item, rater and rating.

Details

Wide data refers to a way of laying out categorical rating data where each item is one row and each column represents the ratings of each rater. Elements of the data can be NA, indicating that an item wasn't rated by a rater. Wide data cannot represent the same rater rating an item multiple times.

Currently any column names of the data are ignored and the raters are labelled by their column position (1 indexed, left to right). Only numeric ratings are currently supported.

Examples

wide_data <- data.frame(dater_1 = c(3, 2, 2), rater_2 = c(4, 2, 2))
wide_data
#>   dater_1 rater_2
#> 1       3       4
#> 2       2       2
#> 3       2       2

long_data <- wide_to_long(wide_data)
long_data
#>   item rater rating
#> 1    1     1      3
#> 2    1     2      4
#> 3    2     1      2
#> 4    2     2      2
#> 5    3     1      2
#> 6    3     2      2