read.csv is not truncating or rounding, but your print.data.frame function is only displaying the values to the precision specified in options(). Try:
print(dfrm, digits=10)
> dfrm<- data.frame(test=-117.2403266)
> print(dfrm)
test
1 -117.2403
> print(dfrm, digits=10)
test
1 -117.2403266
Using format as suggested would show that the precision has not been lost, but it would return a character vector, so it might not be suitable for assignment when a numeric value was expected.
Edit of a 2 yr-old post: This topic might bring up the question regarding how integers can be imported when they are larger than .Machine$integer.max #[1] 2147483647, since such they can now be internally stored exactly as 'numeric'-abscissa values, so that maximum would be 2^52 (or 2^53-1, I forget which it is). When these are read in from a scan-based function (as are all 0f the read.*-family), you would need to declare as 'numeric' rather than 'integer':
> str( scan(text="21474836470", what=integer()))
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
scan() expected 'an integer', got '21474836470'
> str( scan(text="21474836470", what=numeric()))
Read 1 item
num 2.15e+10
> str( read.table(text="21474836470", colClasses="integer"))
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
scan() expected 'an integer', got '21474836470'
> str( read.table(text="21474836470", colClasses="numeric"))
'data.frame': 1 obs. of 1 variable:
$ V1: num 2.15e+10
If you don't specify a type or mode for "what", scan would assume numeric() and it would succeed.
answered 2013-07-23T22:08:46.673