Description Usage Arguments Details Value See Also Examples
View source: R/as.tidytensor.R
Given a vector, matrix, or array, returns a tidytensor. If given a vector, converts to a 1-d array supporting dim(), matrices are left as matrices, and in all cases the class 'tidytensor' is added.
1 | as.tidytensor(x, ...)
|
x |
input to convert to a tidytensor. |
... |
additional arguments to be passed to or from methods (ignored). |
Matrices are synonymous with 2-d arrays, so these are left as is. Vectors are converted to 1-d arrays so that they can support dim().
a new tidytensor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # From an array (representing e.g. 30 26x26 images (30 sets of 26 rows of 26 pixels))
a <- array(rnorm(30 * 26 * 26), dim = c(30, 26, 26))
t <- as.tidytensor(a)
ranknames(t) <- c("sample", "row", "pixel")
print(t)
# From a matrix (representing e.g. a 26x26 image (26 rows of 26 pixels))
m <- matrix(rnorm(26 * 26), nrow = 26, ncol = 26)
t <- as.tidytensor(m)
ranknames(t) <- c("row", "pixel")
print(t)
# From a vector (representing e.g. 26 pixel values)
v <- rnorm(26)
t <- as.tidytensor(v)
ranknames(t) <- c("pixel")
print(t)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.