Hi,
Is there a way to perform Big-endian / Little-endian byte swap in R?
An ugly way is by using readBin/writeBin:
ByteSwap = function(X, size)
{
writeBin(X, "tmp.dat")
readBin("tmp.dat", typeof(X), n = length(x), size=size,
endian="swap")
}
> x = (1:5)*pi
> y = ByteSwap(x,8)
> z = ByteSwap(y,8)
> x
[1] 3.141593 6.283185 9.424778 12.566371 15.707963
> y
[1] 3.207376e-192 3.207376e-192 -4.277269e+87 3.207376e-192
7.596046e+145
> z
[1] 3.141593 6.283185 9.424778 12.566371 15.707963
But, there has to be some way of doing that without use of temporaty files.
Jarek
=====================================\====
Jarek Tuszynski, PhD. o / \
Science Applications International Corporation <\__,|
(703) 676-4192 "> \
Jaroslaw.W.Tuszynski@saic.com ` \
[[alternative HTML version deleted]]