immer_reshape_wideformat: Creating a Rating Dataset in Wide Format

View source: R/immer_reshape_wideformat.R

immer_reshape_wideformatR Documentation

Creating a Rating Dataset in Wide Format

Description

Converts a rating dataset from a long format into a wide format.

Usage

immer_reshape_wideformat(y, pid, rater, Nmin_ratings=1)

Arguments

y

Vector or a data frame containing ratings

pid

Person identifier

rater

Rater identifier

Nmin_ratings

Minimum number of ratings used for selection

Value

Data frame with ratings. Each row corresponds to a person, and each of the columns (except the first one containing the person identifier) to one rater.

Examples

#############################################################################
# EXAMPLE 1: Reshaping ratings of one variable into wide format
#############################################################################

data(data.immer03)
dat <- data.immer03

# select variable "b" and persons which have at least 10 ratings
dfr <- immer::immer_reshape_wideformat( y=dat$b2, pid=dat$idstud, rater=dat$rater,
                    Nmin_ratings=10 )
head(dfr)

#############################################################################
# EXAMPLE 2: Reshaping ratings of a data frame into wide format
#############################################################################

data(data.immer07)
dat <- data.immer07

#*** Dataset 1: Wide format for item I1
dfr1 <- immer::immer_reshape_wideformat( dat$I1, rater=dat$rater, pid=dat$pid)

#*** Dataset 2: Wide format for four items I1, I2, I3 and I4
dfr2 <- immer::immer_reshape_wideformat( dat[, paste0("I",1:4) ],
              rater=dat$rater, pid=dat$pid )
str(dfr2)

immer documentation built on May 29, 2024, 11:52 a.m.