Skip to contents

Converts an IRW-compliant dataset from long format to wide format while handling optional metadata elements, filtering by wave, and ensuring consistency.

Usage

irw_long2resp(df, wave = NULL, id_density_threshold = 0.1, agg_method = "mean")

Arguments

df

A data frame containing IRW-compliant item response data in long format.

wave

(Optional) A numeric value specifying which wave to filter. If the dataset does not have a "wave" column, this input is ignored. Defaults to the most frequent wave if NULL.

id_density_threshold

A numeric value between 0.0 and 1.0 specifying the minimum response density required for an id to be included. Default is 0.1. Set to NULL to disable filtering.

agg_method

A string specifying how to handle multiple id-item pairs. Options: "mean" (default), "mode", "median", "first".

Value

A data frame in wide format where rows represent id values and columns represent item_* responses.

Details

This function applies a default sparsity filter with a threshold of 0.1 for id density to avoid excessive sparsity in the response matrix. Users can disable filtering by setting id_density_threshold = NULL.