Skip to contents

Add a layout column to long format data for mixed layouts.

Usage

add_mixed_layout(
  x,
  rows = "row",
  cols = "col",
  values = "value",
  layout,
  name = "layout"
)

Arguments

x

Long format data frame of a symmetric matrix.

rows, cols, values

Columns containing rows, columns, and values.

layout

Character vector of length two with a mixed layout (two opposing triangles).

name

Name of the column that should contain the layouts.

Value

The input data frame with a new column added, showing in which triangle each value would be in a mixed layout.

Examples

# Make long format symmetric data
long_df <- data.frame(rw = rep(letters[1:4], 4),
                      cl = rep(letters[1:4], each = 4),
                      val = 0)

long_df <- add_mixed_layout(long_df, rw, cl, val,
                            layout = c("topleft", "bottomright"))

head(long_df)
#>   rw cl val      layout
#> 1  a  a   0     topleft
#> 2  b  a   0     topleft
#> 3  c  a   0     topleft
#> 4  d  a   0     topleft
#> 5  a  b   0 bottomright
#> 6  b  b   0     topleft