# matrix2long: Convert a quadratic matrix to long format In TripleR: Social Relation Model (SRM) Analyses for Single or Multiple Groups

## Description

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

## Usage

 `1` ```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

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```#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) ```

### Example output

```Loading required package: ggplot2
'data.frame':	54 obs. of  54 variables:
\$ V1 : int  NA 4 4 3 5 3 5 4 3 3 ...
\$ V2 : int  3 NA 3 3 4 3 3 3 2 3 ...
\$ V3 : int  3 3 NA 3 4 4 4 4 4 3 ...
\$ V4 : int  2 4 3 NA 4 3 3 4 4 3 ...
\$ V5 : int  2 3 3 4 NA 4 4 4 2 3 ...
\$ V6 : int  4 4 3 2 4 NA 5 5 4 4 ...
\$ V7 : int  3 3 4 1 3 5 NA 5 4 4 ...
\$ V8 : int  3 2 3 2 2 5 5 NA 4 4 ...
\$ V9 : int  2 2 2 3 3 3 4 4 NA 2 ...
\$ V10: int  3 3 3 2 3 4 3 5 2 NA ...
\$ V11: int  3 2 2 2 4 5 3 4 3 4 ...
\$ V12: int  2 3 3 4 3 4 3 4 3 3 ...
\$ V13: int  2 3 1 2 2 4 3 3 3 2 ...
\$ V14: int  3 3 4 3 4 5 4 5 5 3 ...
\$ V15: int  2 4 2 2 3 4 3 3 1 3 ...
\$ V16: int  3 3 4 3 4 5 5 4 4 3 ...
\$ V17: int  2 2 0 2 3 4 3 2 2 1 ...
\$ V18: int  3 3 3 4 4 4 4 4 3 4 ...
\$ V19: int  2 3 2 4 4 5 3 3 2 2 ...
\$ V20: int  3 4 3 3 4 5 4 4 4 4 ...
\$ V21: int  2 4 2 3 2 4 4 3 3 2 ...
\$ V22: int  2 4 3 3 3 5 3 3 3 3 ...
\$ V23: int  3 3 3 2 3 4 3 2 3 2 ...
\$ V24: int  3 4 2 2 4 3 3 3 3 2 ...
\$ V25: int  3 3 1 3 3 3 3 3 3 4 ...
\$ V26: int  3 4 2 3 4 4 3 3 3 3 ...
\$ V27: int  3 4 3 3 4 5 3 4 4 3 ...
\$ V28: int  3 3 2 3 4 5 4 4 3 4 ...
\$ V29: int  3 4 3 3 3 4 5 4 3 3 ...
\$ V30: int  2 4 2 3 3 4 3 3 5 2 ...
\$ V31: int  2 4 4 2 3 5 3 4 1 4 ...
\$ V32: int  3 4 2 3 4 4 3 3 3 2 ...
\$ V33: int  1 4 4 4 4 3 4 4 2 2 ...
\$ V34: int  3 4 4 3 2 5 4 4 4 3 ...
\$ V35: int  3 4 3 3 4 4 4 3 3 1 ...
\$ V36: int  3 2 2 3 4 5 3 4 3 3 ...
\$ V37: int  2 3 3 2 4 5 4 3 4 3 ...
\$ V38: int  2 4 3 4 4 4 3 4 2 2 ...
\$ V39: int  3 4 3 3 3 4 3 4 3 2 ...
\$ V40: int  3 4 2 3 3 4 3 4 4 3 ...
\$ V41: int  3 4 4 3 4 5 4 4 4 4 ...
\$ V42: int  3 4 3 3 4 4 3 3 3 2 ...
\$ V43: int  3 4 2 3 4 4 4 3 3 1 ...
\$ V44: int  3 3 4 4 3 5 4 4 4 3 ...
\$ V45: int  2 4 3 3 3 3 4 4 4 2 ...
\$ V46: int  3 3 2 2 3 4 3 3 2 2 ...
\$ V47: int  3 4 3 3 3 3 3 3 3 2 ...
\$ V48: int  3 4 4 3 2 5 4 4 4 3 ...
\$ V49: int  3 3 4 3 4 4 5 4 4 4 ...
\$ V50: int  3 4 3 3 3 4 4 4 3 2 ...
\$ V51: int  3 3 3 3 2 5 5 4 4 3 ...
\$ V52: int  3 4 4 3 3 5 4 4 4 4 ...
\$ V53: int  3 4 4 3 3 5 4 4 5 4 ...
\$ V54: int  3 4 3 2 3 5 4 3 4 2 ...
'data.frame':	2916 obs. of  3 variables:
\$ actor.id  : int  1 2 3 4 5 6 7 8 9 10 ...
\$ partner.id: int  1 1 1 1 1 1 1 1 1 1 ...
\$ value     : int  NA 4 4 3 5 3 5 4 3 3 ...
```

TripleR documentation built on May 2, 2019, 1:08 p.m.