Dear Ulas,

A number of people have suggested changing the print precision via the
digits argument to print(), and have explained that what you see when a
number is printed doesn't necessarily reflect the precision of the stored
number. You can also reset the digits option, which defaults to 7. (You'll
still lose trailing zeroes, however.) For you example:

> options(digits=10)
> mdat
            [,1]        [,2]        [,3]        [,4]
[1,] 0.018797295 1.000000000 0.010500242 0.074216423
[2,] 0.444620855 0.000320438 1.108755638 0.036289824

I hope this helps,
 John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
-------------------------------- 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Ulas Karaoz
> Sent: Thursday, January 06, 2005 6:57 PM
> To: R-help@stat.math.ethz.ch
> Subject: [R] How to avoid rounding of matrix elements?
> 
> Hi all R-users,
> If I have a matrix with numeric elements as follows, the 
> values are rounded when I try to refer to a specifici element 
> using [], the value is rounded.
> The same thing happens if the matrix is read from a file, the 
> values are stored to the correct precision but then when I 
> try to refer to a specific element (such as using [], it is rounded.
> 
> How do I avoid this rounding?
>  
> >mdat<-matrix(c(0.0187972950,0.4446208550,1.0000000000,0.00032
> 04380,0.0105002420,1.1087556380,0.0742164230,0.0362898240),
> nrow = 2, ncol=4)
>  > mdat
>            [,1]        [,2]       [,3]       [,4]
> [1,] 0.01879729 1.000000000 0.01050024 0.07421642 [2,] 
> 0.44462085 0.000320438 1.10875564 0.03628982
> 
> Thanks.
> 
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to