gregory_r_warnes@groton.pfizer.com
2003-May-20 15:41 UTC
[Rd] FW: print.matrix incorrectly formatting string matrixes when righ (PR#3058)
> When printing a string matrix with right=TRUE and na.print specified, an > incorrect amount of spaced is provided for NA columns leading to incorrect > formatting: > > > > a <- matrix( c(NA, "a", "b", "10", > + NA, NA, "d", "12", > + NA, NA, NA, "14"), > + byrow=T, ncol=4 ) > > print(a) # correct > [,1] [,2] [,3] [,4] > [1,] NA "a" "b" "10" > [2,] NA NA "d" "12" > [3,] NA NA NA "14" > > print(a, right=T) # correct > [,1] [,2] [,3] [,4] > [1,] NA "a" "b" "10" > [2,] NA NA "d" "12" > [3,] NA NA NA "14" > > print(a, right=T, na.print=" ") # wrong > [,1] [,2] [,3] [,4] > [1,] "a" "b" "10" > [2,] "d" "12" > [3,] "14" > > print(a, right=T, na.print=" ") # wrong > [,1] [,2] [,3] [,4] > [1,] "a" "b" "10" > [2,] "d" "12" > [3,] "14" > > > > > This does not occur with numeric matrixes: > > > a <- matrix( c(NA, 1.0, 2.0, 3.0, > + NA, NA, 4.0, 5.0, > + NA, NA, NA, 6.0 ), > > + byrow=T, ncol=4 ) > > print(a) > [,1] [,2] [,3] [,4] > [1,] NA 1 2 3 > [2,] NA NA 4 5 > [3,] NA NA NA 6 > > print(a,right=T) > [,1] [,2] [,3] [,4] > [1,] NA 1 2 3 > [2,] NA NA 4 5 > [3,] NA NA NA 6 > > print(a,right=T,na.print=" ") > [,1] [,2] [,3] [,4] > [1,] 1 2 3 > [2,] 4 5 > [3,] 6 > > print(a, right=T, na.print=" ") > [,1] [,2] [,3] [,4] > [1,] 1 2 3 > [2,] 4 5 > [3,] 6 > > >LEGAL NOTICE\ Unless expressly stated otherwise, this message is... {{dropped}}
Prof Brian Ripley
2003-May-20 17:02 UTC
(PR#3058) [Rd] FW: print.matrix incorrectly formatting string matrixes when right=T
Fixed for R-patched. Note that right=TRUE (sic) is not used for numeric matrices: it is the default and cannot be altered. On Tue, 20 May 2003 gregory_r_warnes@groton.pfizer.com wrote:> > > When printing a string matrix with right=TRUE and na.print specified, an > > incorrect amount of spaced is provided for NA columns leading to incorrect > > formatting: > > > > > > > a <- matrix( c(NA, "a", "b", "10", > > + NA, NA, "d", "12", > > + NA, NA, NA, "14"), > > + byrow=T, ncol=4 ) > > > print(a) # correct > > [,1] [,2] [,3] [,4] > > [1,] NA "a" "b" "10" > > [2,] NA NA "d" "12" > > [3,] NA NA NA "14" > > > print(a, right=T) # correct > > [,1] [,2] [,3] [,4] > > [1,] NA "a" "b" "10" > > [2,] NA NA "d" "12" > > [3,] NA NA NA "14" > > > print(a, right=T, na.print=" ") # wrong > > [,1] [,2] [,3] [,4] > > [1,] "a" "b" "10" > > [2,] "d" "12" > > [3,] "14" > > > print(a, right=T, na.print=" ") # wrong > > [,1] [,2] [,3] [,4] > > [1,] "a" "b" "10" > > [2,] "d" "12" > > [3,] "14" > > > > > > > > > This does not occur with numeric matrixes: > > > > > a <- matrix( c(NA, 1.0, 2.0, 3.0, > > + NA, NA, 4.0, 5.0, > > + NA, NA, NA, 6.0 ), > > > > + byrow=T, ncol=4 ) > > > print(a) > > [,1] [,2] [,3] [,4] > > [1,] NA 1 2 3 > > [2,] NA NA 4 5 > > [3,] NA NA NA 6 > > > print(a,right=T) > > [,1] [,2] [,3] [,4] > > [1,] NA 1 2 3 > > [2,] NA NA 4 5 > > [3,] NA NA NA 6 > > > print(a,right=T,na.print=" ") > > [,1] [,2] [,3] [,4] > > [1,] 1 2 3 > > [2,] 4 5 > > [3,] 6 > > > print(a, right=T, na.print=" ") > > [,1] [,2] [,3] [,4] > > [1,] 1 2 3 > > [2,] 4 5 > > [3,] 6 > > > > >-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595