Skip to content
Prev 10421 / 63421 Next

File Reading Problem (PR#4043)

On Mon, 1 Sep 2003 22:32:29 +0200 (MET DST), you wrote:

            
The problem was that the R code assumed 'c' was a storage mode, and
the C code assumed that it had already been checked as valid.  I'll
put a patch into r-devel.

The answer to the original question is to use readChar, not readBin.
readBin looks for C-style null terminated strings.  readChar can read
characters one at a time.

The right code to read "This is a book." from file foo.txt is

 readChar("foo.txt", rep(1, 15))

Duncan Murdoch