df_to_array: Convert a data.frame to array format.

Description Usage Arguments Value Examples

View source: R/df_to_array.R

Description

Convert a data.frame to array format.

Usage

1
df_to_array(df, indexes)

Arguments

df

A data.frame with the indexes columns and a value column.

indexes

A names list with the indexes for the array.

Value

An array with the indexes dimension.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(emr)

set1 <- c("A", "B")
set2 <- c("C", "D")
set3 <- c("imp", "exp")
sets <- list(
 set1 = set1,
 set2 = set2,
 set3 = set3
)
x <- expand.grid(
  set1 = set1,
  set2 = set2,
  set3 = set3,
  stringsAsFactors = TRUE
)
x$value <- 1:8
df_to_array(x, sets[(c('set1', 'set2', 'set3'))])

paulofelipe/emr documentation built on July 23, 2021, 7:31 p.m.