Learn R Programming

ctypesio (version 0.1.2)

flip_endian: Flip the endianness of elements in a vector

Description

This will create a new vector with the values reversed within the given block size. This can be used for changing the endianness of a set of values

Usage

flip_endian(x, size)

Value

A vector of the same type as the initial vector with the values within each block reversed.

Arguments

x

vector. Usually a raw vector, but can be any type

size

block size. Usually a power of 2.

See Also

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

Examples

Run this code
vec <- c(1, 2, 3, 4)
flip_endian(vec, 1)   # should give: c(1, 2, 3, 4)
flip_endian(vec, 2)   # should give: c(2, 1, 4, 3)
flip_endian(vec, 4)   # should give: c(4, 3, 2, 1)

Run the code above in your browser using DataLab