>>>>> "Yudi" == Yudi Pawitan <yudi at ucd.ie>
writes:
Yudi> Is there facility in R to read binary file? In Splus scan() has
Yudi> 'width=' argument and AsciiToInt() command to translate the
Yudi> binary data. Is there something similar in R?
hmm, two things ---rather thoughts than proposals---
- ASCII is 7bit, binary is 8bit;
but indeed: S-plus' AsciiToInt(ch) [formerly known as ichar()]
works for 8bit strings as well.
- in R, we allow for ``8bit extended ASCII'' (actually iso-latin-1)
which enables us non-English speakers (and writers) to use our language
"accents", and, using using 'locale's even to sort
accordingly.
The drawback of our `localized' approach is that AsciiToInt()
---if we'd implement it--- would be localized as well
{but then scan(what="") would be too, and then reading binary, using
this
hack should work, locale-independently...}.
Maybe a better approach would be to directly read binary bytes into
integers, 2 or 4 bytes into one integer
(R requires C integers with at least 32 bits).
The two simple function pack8bit() and unpack8bit() which are now part of
the wavethresh package on CRAN {{and are applied to store the
picture of John Lennon more efficiently}}
could come handy here.
Martin Maechler <maechler at stat.math.ethz.ch>
http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum LEO D10 Leonhardstr. 27
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408 fax: ...-1228 <><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._