[R] WriteBin problem

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Nov 6 17:05:27 CET 2013


Sorry, Carl, but you missed the boat on both responses.

Using readBin to read what they wrote won't help the OP if they don't understand what they are writing.  Nor is byte 0 the EOF marker on any operating system I have ever used. (It does happen to be the string terminator for in-memory strings in the C language, and it is actually not unusual to find NUL-termination used in strings that are stored in binary files. The OP does seem to be confused about the difference between binary files and text files, both of which can be affected by the disk format, CPU type, and operating system that are in use.)

I recommend that the OP use raw vectors (see ?raw) if they want to read and write binary data. I also recommend using the hexView package to manipulate the contents of raw vectors.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Carl Witthoft <carl at witthoft.com> wrote:
>
>First of all,  use "readBin" to verify you get the desired data back.  
>Second, that '00' is, I believe the <EOF> character you'll find at the
>end
>of any file.
>
>
>Harutyun Khachatryan wrote
>> Dear R project officials,
>> 
>> I have found that in R 3.0.1 version "writeBin" function of "base"
>package
>> might not work correctly. For command writeBin("100",raw()) it
>answers "31
>> 30 30 00" the last double 0 is differs from
>> http://www.branah.com/ascii-converter there ascii codes are "31 30
>30". So
>> is it normal having double 0-s after ascii codes and what it means? 
>
>
>
>
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/WriteBin-problem-tp4679853p4679855.html
>Sent from the R help mailing list archive at Nabble.com.
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>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 mailing list