R 3.1.0 is out and one of the new features is the following:
type.convert()
(and hence by defaultread.table()
) returns a ch
Try using data.table's fread
:
# create test data set "a.dat"
Lines <- "num1 num2\n1.1 1.1234567890123456\n2.2 2.2\n3.3 3.3\n"
cat(Lines, file = "a.dat")
#####
library(data.table)
DT <- fread("a.dat")
str(DT)
## Classes ‘data.table’ and 'data.frame': 3 obs. of 2 variables:
## $ num1: num 1.1 2.2 3.3
## $ num2: num 1.12 2.2 3.3
## - attr(*, ".internal.selfref")=
class(DT)
## [1] "data.table" "data.frame"
DF <- as.data.frame(DT)
class(DF)
## [1] "data.frame"
ADDED LATER Since this answer was posted the latest patched version of R 3.1.0 has come out and by default reverts back to the old behavior with a new numerals
argument to specify it differently. See type.convert and read.table