[R] Decoding raw vectors every other byte
hb at stat.berkeley.edu
Wed Jun 16 13:37:49 CEST 2010
x <- 1:10;
dim(x) <- c(length(x)/2, 2);
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
If length(x) is odd, some care is needed, e.g. x <- matrix(x, ncol=2,
On Wed, Jun 16, 2010 at 1:15 PM, Alex van der Spek <doorz at xs4all.nl> wrote:
> I have to decode raw vectors read from a connection like this:
> The decoding performs a combination of a simple bitwise operator and a
> simple arithmatic operator on every other byte in the raw vector dat.
> I can code this using a for loop (incrementing the loop counter by 2 every
> pass) but would rather use vectorized operations for reasons of speed. I
> can create a function with a for loop and vectorize that function but is
> there perhaps an easier way to write this? It is enough if this works on
> windows only. No need to worry about endianness.
> Thanks in advance.
> Alex van der Spek
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help