matrix2long: Convert a quadratic matrix to long format

View source: R/long2matrix.R

matrix2longR Documentation

Convert a quadratic matrix to long format

Description

This function converts data from a quadratic round robin matrix into long format.

Usage

matrix2long(M, new.ids=TRUE, var.id="value")

Arguments

M

A matrix with actors in rows and partners in columns)

new.ids

Should new ids for actors and partners be defined? (If new.ids=FALSE the row and column names are taken. In that case, you have to make sure, that rows and columns have the same set of names.)

var.id

The name of the column with the measured variable in the returned data frame

Value

A data frame in long format

See Also

long2matrix

Examples

#The example data are taken from the "Mainz Freshman Study" and consist 
# of ratings of liking as well as ratings of the metaperception of 
# liking at zero-acquaintance using a Round-Robin group of 54 participants 
# (Back, Schmukle, & Egloff, in pres)

# load a data set in matrix style
data("liking_a")

str(liking_a)
long <- matrix2long(liking_a)

str(long)
 

TripleR documentation built on April 26, 2022, 5:08 p.m.