as.list.tidytensor: Convert a tidytensor into a nested list of tensors.

Description Usage Arguments Details Value See Also Examples

Description

Convert a tidytensor into a nested list of tensors, nested down to level specified in rank. If flatten = TRUE, returns a flattens the structure to a list of tensors (not nested).

Usage

1
2
## S3 method for class 'tidytensor'
as.list(x, rank = 1, flatten = TRUE, state = NULL, ...)

Arguments

x

the tidytensor to convert.

rank

an indicator of the rank defining the contained tensors.

flatten

whether to return a nested list (FALSE) or a flattened list (TRUE).

state

an internally used parameter for tracking build state-do not set manually.

...

additional arguments passed to methods (unusued).

Details

The state parameter is for internal use, and needn't be set during normal usage.

Value

a list.

See Also

as.data.frame.tidytensor

Examples

1
2
3
4
5
# Three tidytensors of the same shape
t1 <- as.tidytensor(array(100 * 1:(3 * 4 * 5), dim = c(3, 4, 5)))
ranknames(t1) <- c("sample", "row", "col")
l1 <- as.list(t1)
str(l1)

oneilsh/tidytensor documentation built on Oct. 11, 2021, 11:43 p.m.