R 3.1.0 is out and one of the new features is the following:
type.convert()
(and hence by defaultread.table()
) returns a character vector or factor when representing a numeric input as a double would lose accuracy. Similarly for complex inputs.
To give an example:
df <- read.table(text = "num1 num2
1.1 1.1234567890123456
2.2 2.2
3.3 3.3", header = TRUE)
sapply(df, class)
# num1 num2
# "numeric" "factor"
while with previous versions, read.table
would have returned two numeric columns.
For those who like me are a concerned about that change, what can be done to preserve the old behavior?
Note: I'd like a general solution that does not make assumptions on the input data, i.e. do not suggest I use colClasses = "numeric"
in the example above. Thanks.