Skip to content

using scan function

2 messages · arun

#
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
#
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