View source: R/immer_reshape_wideformat.R
immer_reshape_wideformat | R Documentation |
Converts a rating dataset from a long format into a wide format.
immer_reshape_wideformat(y, pid, rater, Nmin_ratings=1)
y |
Vector or a data frame containing ratings |
pid |
Person identifier |
rater |
Rater identifier |
Nmin_ratings |
Minimum number of ratings used for selection |
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.
############################################################################# # 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.