set_dimnames: Set dimnames() via a standard function call.

Description Usage Arguments Details Value See Also Examples

Description

Since tidytensors are arrays, they support dimnames(). The usuall syntax dimnames(x) <- works; this function provides a Magritte-compatible regular function, set_dimnames(x, newnames) which returns a new tidytensor.

Usage

1
set_dimnames(x, newnames, ...)

Arguments

x

input tidytensor to set dimnames on.

newnames

list of dimnames to assign.

...

additional arguments to be passed to or from methods (ignored).

Details

Setting dimnames with set_dimnames() preserves any ranknames present.

Value

a tidytensor with dimnames set.

See Also

ranknames<-, dimnames

Examples

1
2
3
4
5
6
7
t <- as.tidytensor(array(1:(3 * 2), dim = c(3, 2)))
t <- set_dimnames(t, list(c("sample1", "sample2", "sample3"), c("valset1", "valset2")))
print(t)

# We can also assign ranknames:
ranknames(t) <- c("sample", "valset")
print(t)

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