[R] scan() Bug?

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jan 22 22:52:14 CET 2004

On Thu, 22 Jan 2004, Greg Riddick wrote:

> I'm reading a file into a list by:
> PDF = scan("file",what="character",sep="\10")
> "\10" is the newline character in this file, also tried "\n" originally
> On lines that are ended by "\13\10", both are dropped from the list entry
> I want scan to keep the "\13" in the list entry.
> Is this a bug or just a strange feature?

Not a strange feature, but the documented behaviour (and useful, too).  
You have opened the file in text mode.  If you want to keep CRs, open and
read in binary mode.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list