[R] Question about type conversion in read.table with columns that contain "+" and "-" in R > 2.7

Prof Brian Ripley
Mon, 01 Sep 2008 21:17:10 -0000

On Mon, 1 Sep 2008, Tim Beissbarth wrote:

> Somewhere in between the R-Versions 2.6 and 2.7 the behaviour of the
function
> type.convert and therefore also read.table, read.csv, etc. has changed (see
> below):
>
> In 2.6 and before:
>> type.convert(c("+", "-", "+"))
> [1] + - +
> Levels: + -
>
> In 2.7 and later:

No, 2.7.0 only.

>> type.convert(c("+", "-", "+"))
> [1] 0 0 0
>
> Apparently, the character strings "+" and "-" are now
interpreted as numeric
> and not any more as factors or character strings.
>
> I have quite a number of files with columns that contain "+" or
"-" and would
> like to convert these to characters or factors, without having to specify
the
> individual column types manually.
>
> Is there any way to still do so in a new version of R?

Even an old version of R (2.7.1)!

Please do note what the posting guide says about updating *before*
posting, and using proper version numbers (there is no 'R 2.7')

> Many thanks and best wishes,
> Tim
>
> ______________________________________________
> 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.
>

--
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