Description Usage Arguments Value Examples
Convert a data.frame to array format.
1 | df_to_array(df, indexes)
|
df |
A data.frame with the indexes columns and a value column. |
indexes |
A names list with the indexes for the array. |
An array with the indexes dimension.
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'))])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.