smyth@wehi.edu.au
2005-Jul-27 02:52 UTC
[Rd] R 2.1.1: read.table processes C-style escapes (PR#8037)
In R 2.1.1, the default behaviour of scan() was changed to process all
C-style escapes, even when a delimiter was specified using the 'sep'
argument. A new argument 'allowEscapes' was introduced to turn this
processing off.
Because read.table() calls scan(), read.table() inherits the new default
behaviour of scan() but without a way to turn it off. For example, reading
a file testdata.txt' containing
X
A
\0
C
produces
> read.delim("testdata.txt")
[1] X
<0 rows> (or 0-length row.names)
It seems that all the occurances of scan() within read.table() need to have
'allowEscapes=FALSE' added to the argument string.
Gordon
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status Patched
major 2
minor 1.1
year 2005
month 07
day 22
language R
---------------------------------------------------------------------------------------
Dr Gordon K Smyth, Senior Research Scientist, Bioinformatics,
Walter and Eliza Hall Institute of Medical Research,
1G Royal Parade, Parkville, Vic 3050, Australia
Tel: (03) 9345 2326, Fax (03) 9347 0852,
Email: smyth at wehi.edu.au, www: http://www.statsci.org
Gordon Smyth
2005-Jul-27 04:20 UTC
[Rd] R 2.1.1: read.table processes C-style escapes (PR#8037)
>To: r-bugs at biostat.ku.dk >From: Gordon Smyth <smyth at wehi.edu.au> >Subject: R 2.1.1: read.table processes C-style escapes >Date: Wed, 27 Jul 2005 12:51:45 +1000 > >In R 2.1.1, the default behaviour of scan() was changed to process all >C-style escapes, even when a delimiter was specified using the 'sep' >argument. A new argument 'allowEscapes' was introduced to turn this >processing off. > >Because read.table() calls scan(), read.table() inherits the new default >behaviour of scan() but without a way to turn it off. For example, reading >a file testdata.txt' containing > >X >A >\0 >C > >produces > > > read.delim("testdata.txt") >[1] X ><0 rows> (or 0-length row.names) > >It seems that all the occurances of scan() within read.table() need to >have 'allowEscapes=FALSE' added to the argument string.Or, alternatively and perhaps better, scan() could regain some of its earlier behaviour, to process C-style escapes by default only when 'sep' is NULL or empty. It seems, to me at least, that C-style escape sequences make sense only in some sort of source code, and delimited text can't be source code. Gordon>Gordon > > > version > _ >platform i386-pc-mingw32 >arch i386 >os mingw32 >system i386, mingw32 >status Patched >major 2 >minor 1.1 >year 2005 >month 07 >day 22 >language R
Prof Brian Ripley
2005-Jul-27 07:21 UTC
[Rd] R 2.1.1: read.table processes C-style escapes (PR#8037)
On Wed, 27 Jul 2005, Gordon Smyth wrote:> Thanks for the reply. Apologies for checking only R patched rather than > R-devel. > > I guess that this means that someone must have a use for allowEscapes=TRUE > when read reading a file in table format into a data frame. It is hard to > imagine.Octal and hex escapes are a common way to cope with different encodings. I would not want R limited by the imagination of a single user, let alone a Windows-only user. -- 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
Apparently Analagous Threads
- Infinite degrees of freedom for F-distribution
- Interpretation of escaped characters in \examples{}
- formal methods and classes and capitalization conventions
- Standardized Pearson residuals (and score tests)
- R CMD check: is it error to setMethod for class not currently defined?