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

Tim Beissbarth t.beissbarth at dkfz-heidelberg.de
Mon Sep 1 22:24:23 CEST 2008


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

Many thanks and best wishes,
Tim



More information about the R-help mailing list