data_conversion: Switch data format from rankings to orderings and vice versa

View source: R/MSmix_functions_package.R

data_conversionR Documentation

Switch data format from rankings to orderings and vice versa

Description

Convert the format of the input dataset from rankings to orderings and vice versa. Differently from existing analogous functions supplied by other R packages, data_conversion supports also partial rankings/orderings with arbitrary patterns of censoring.

Usage

data_conversion(data, subset = NULL)

Arguments

data

Integer N\timesn matrix with partial sequences (either rankings or orderings) in each row, whose format has to be converted. Missing entries must be coded as NA.

subset

Optional logical or integer vector specifying the subset of observations, i.e. rows of data, to be kept. Missing values are taken as FALSE. Defaults to NULL meaning that all the rows are considered.

Value

Integer N\timesn matrix of partial sequences with inverse format with respect to the input data.

Examples


## Example 1. Switch the data format for a single complete observation.
data_conversion(c(4, 5, 1, 3, 2))

## Example 2. Switch the data format for partial sequences with arbitrary censoring patterns.
data_conversion(rbind(c(NA, 2, 5, NA, NA), c(4, NA, 2, NA, 3), c(4, 5, 1, NA, NA),
                      c(NA, NA, NA, NA, 2), c(NA, 5, 2, 1, 3), c(3, 5, 1, 2, 4)))


MSmix documentation built on April 3, 2025, 9:29 p.m.