[R] Number of digits to display?
William Dunlap
wdunlap at tibco.com
Mon Oct 26 20:37:10 CET 2015
> myMatrix <- outer(c(1,24,30,75,96), 20:25, "/")
> print(myMatrix, digits=3)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 0.05 0.0476 0.0455 0.0435 0.0417 0.04
[2,] 1.20 1.1429 1.0909 1.0435 1.0000 0.96
[3,] 1.50 1.4286 1.3636 1.3043 1.2500 1.20
[4,] 3.75 3.5714 3.4091 3.2609 3.1250 3.00
[5,] 4.80 4.5714 4.3636 4.1739 4.0000 3.84
> MASS::fractions(myMatrix)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1/20 1/21 1/22 1/23 1/24 1/25
[2,] 6/5 8/7 12/11 24/23 1 24/25
[3,] 3/2 10/7 15/11 30/23 5/4 6/5
[4,] 15/4 25/7 75/22 75/23 25/8 3
[5,] 24/5 32/7 48/11 96/23 4 96/25
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Oct 26, 2015 at 9:43 AM, Judson <judsonblake at msn.com> wrote:
> How do I control the number of digits to display,
> say, in a matrix, without rounding or losing accuracy
> in subsequent calculations?
> round() of course reduces accuracy.
>
> Also, if all my results
> are really fractions, is there a way to display
> them as fractions of integers rather than
> decimal expressions?
>
> ................... judson blake
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list