ArrayToList | R Documentation |
This function splits an array into a list as required by PlotLayout function from package "s2dv" when parameter 'special_args' is used. The function ArrayToList allows to add names to the elements of the list in two different levels, the 'list' or the 'sublist'.
ArrayToList(data, dim, level = "list", names = NULL)
data |
A multidimensional array. |
dim |
A character string indicating the name of the dimension to split or an integer indicating the position of the dimension. |
level |
A string character 'list' or 'sublist' indicating if it should be a list or a sublist. By default it creates a list. |
names |
A vector of character strings to name the list (if it is a single string, it would be reused) or a single character string to name the elements in the sublist. |
A list of arrays of the length of the dimension set in parameter 'dim'.
PlotLayout
data <- array(1:240, c(month = 12, member = 5, time = 4))
# Create a list:
datalist <- ArrayToList(data, dim = 'month', level = 'list', names = month.name)
class(datalist)
class(datalist[[1]])
str(datalist)
# Create a sublist:
datalist <- ArrayToList(data, dim = 'month', level = 'sublist', names = 'dots')
class(datalist)
class(datalist[[1]])
class(datalist[[1]][[1]])
str(datalist)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.