[Rd] FW: print.matrix incorrectly formatting string matrixes when righ (PR#3058)

gregory_r_warnes at groton.pfizer.com gregory_r_warnes at groton.pfizer.com
Tue May 20 16:41:16 MEST 2003


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



More information about the R-devel mailing list