array_melt {supportR}R Documentation

Melt an Array into a Dataframe

Description

Melts an array of dimensions x, y, and z into a dataframe containing columns x, y, z, and value where value is whatever was stored in the array at those coordinates.

Usage

array_melt(array = NULL)

Arguments

array

(array) array object to melt into a dataframe

Value

(dataframe) object containing the "flattened" array in dataframe format

Examples

# First we need to create an array to melt
## Make data to fill the array
vec1 <- c(5, 9, 3)
vec2 <- c(10:15)

## Create dimension names (x = col, y = row, z = which matrix)
x_vals <- c("Col_1","Col_2","Col_3")
y_vals <- c("Row_1","Row_2","Row_3")
z_vals <- c("Mat_1","Mat_2")

## Make an array from these components
g <- array(data = c(vec1, vec2), dim = c(3, 3, 2),
           dimnames = list(x_vals, y_vals, z_vals))

## "Melt" the array into a dataframe
array_melt(array = g)


[Package supportR version 1.3.0 Index]