[R] using scan function

arun smartpink111 at yahoo.com
Tue Nov 12 21:02:00 CET 2013


Hi,
You may try:
op <- options(digits=12)
r1 <- 4; c1 <- 4
 A <- matrix(scan("file1.txt",n=r1*c1),r1,c1,byrow=TRUE)

options(op) #reset

A.K.





Dear all, 
I’m using 'scan' function to import data into a matrix from a .txt 
file. The data are numbers with 12 significant digits (e.g. 
471773.309872).   
When I give the command: 

A <- matrix(scan(file_name, n=r*c), r, c, byrow=TRUE) 

numbers are stored in the matrix with only 7 significant digits 
(e.g. 471773.3). How can I increase the number of significant digits? 

Thank you for your reply. 
Eleonora



More information about the R-help mailing list