[R] readBin which has two different sizes
Ab Hu
master.rstat at yahoo.com
Mon Oct 4 03:56:46 CEST 2010
Henrik Bengtsson wrote:
>
>
> 1. Use x <- readBin(..., what="raw", n=35269*(54*4)) to read your raw
> ("byte") data.
> 2. Turn it into a 54x4x35269 array, e.g. dim(x) <- c(54,4,35269).
> 3. Extract the 4-byte time stamps by yT <- x[1:4,,,drop=FALSE]; This
> is of type "raw". Use readBin() to parse it, i.e. zT <- readBin(yT,
> what="integer", size=4, signed=TRUE, endian="big"). There are your
> timestamps.
> 4. Extract the 50 1-byte samples by yS <- x[5:54,,,drop=FALSE]; zS <-
> readBin(yS, what="integer", size=1, signed=FALSE);
>
> Something like that.
>
> /Henrik
>
Tried it and it works great. I had to make just one adjustment, i.e. specify
the size of n, which I did using length:
yT <- x[1:4,,,drop=FALSE]
zT <- readBin(yT, what="integer", size=4, n=length(yT), signed=FALSE,
endian="big")
yS <- x[5:54,,,drop=FALSE];
zS <- readBin(yS, what="integer", size=1, n=length(yS), signed=TRUE)
Thanks Henrik!
--
View this message in context: http://r.789695.n4.nabble.com/readBin-which-has-two-different-sizes-tp2953365p2953721.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list