df_to_array | R Documentation |
Convert a Data Frame of array entries (as returned by dplyr::summarise
) to an Array containing the entries
df_to_array(x, l)
x |
data frame where each row represents the index of a value, along with the value itself (as returned by the summarise method in library dplyr) |
l |
list of reference vectors whose lengths give the dimensions of the output array (first vector length first dimension of the output, etc.) |
Array whose dimensions match the dimensions of l and whose entries represent data for the corresponding indices from x. Non-specified entries are assumed to be zero. For example, if inputs are:
x = 1 1 7 l = list(c(1,2), c(1,7,9)) 1 2 5 ^ ^ 2 2 1 | | 2 3 2 | second dimension is of length length(c(1,7,9)) = 3 ^ ^ ^ first dimension is of length length(c(1,2)) = 2 | | | | | values for each index | second dimension indices first dimension indices Then the output will be: res = [7 5 0 <-- 2 x 3 array with values as specified by the last column of x, and other entries zero 0 1 2]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.