as.array.list: Coerce a list to an array

Description Usage Arguments Value Examples

View source: R/as.array.list.R

Description

Coerce a list consisting of data.frames or matrices of equal size to a 3d array

Usage

1
2
## S3 method for class 'list'
as.array(x, ...)

Arguments

x

a list of equal sized data.frames or matrices

...

(not used)

Value

A list of length l with elements of m rows and n columns wix result in an m × n × l array.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
df1 <- data.frame(x=c(1, 2, 3), y=c(2, 3, 4), z=c(3, 4, 5))
df2 <- data.frame(x=c(4, 2, 3), y=c(2, 5, 4), z=c(3, 4, 6))
df3 <- data.frame(x=c(1, 4, 2), y=c(3, 3, 8), z=c(4, 3, 5))

l <- list(df1, df2, df3)

as.array(l)

llm <- list(matrix(LETTERS[1:6], 2), 
            matrix(LETTERS[7:12], 2))

as.array(llm)

as.array(speedskate)

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.