Skip to content

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

2 messages · Tim Beissbarth, Brian Ripley

#
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
#
On Mon, 1 Sep 2008, Tim Beissbarth wrote:

            
No, 2.7.0 only.
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')