aperm_vector_to_array: Permute a linear vector of data into an R array

View source: R/endian.R

aperm_vector_to_arrayR Documentation

Permute a linear vector of data into an R array

Description

Permute a linear vector of data into an R array

Usage

aperm_vector_to_array(x, src, flipy = FALSE, simplify_matrix = TRUE)

Arguments

x

vector

src

Specification of source dimensions in the order of presentation in the source data. This must a named integer vector with the names "planes", "rows", "cols" (and their corresponding sizes) in the order in which they occur in the data. The first named element must always be "planes". Use planes = 1 to indicate that this is matrix data.

flipy

flip the array vertically. Default: FALSE

simplify_matrix

If the resulting array only has a single plane, should this be simplified to a matrix? Default: TRUE

Value

array or matrix

See Also

Other data permutation functions: aperm_array_to_vector(), flip_endian()

Examples

# Convert a vector of packed RGB data to an array with 3 planes
x <- c(
  'r0', 'g0', 'b0',   'r1', 'g1', 'b1',   'r2', 'g2', 'b2',   
  'r3', 'g3', 'b3',   'r4', 'g4', 'b4',   'r5', 'g5', 'b5'
)
aperm_vector_to_array(x, src = c(planes = 3, cols = 3, rows = 2))

ctypesio documentation built on April 3, 2025, 7:28 p.m.