[R] Non-alignment of <NA> from print.data.frame()

Don MacQueen macq at llnl.gov
Wed May 1 21:53:21 CEST 2002


The use of <NA> to indicate "missing" when printing in a non-quoted 
context seems like a good idea to me. But it appears to have a 
side-effect:

>  foo <- data.frame(x=1:5,ch=c('a','b',NA,'c','d'),gr=rep('ab',5))
>  foo
   x   ch gr
1 1    a ab
2 2    b ab
3 3   <NA> ab
4 4    c ab
5 5    d ab
>  version
          _
platform sparc-sun-solaris2.7
arch     sparc
os       solaris2.7
system   sparc, solaris2.7
status
major    1
minor    5.0
year     2002
month    04
day      29
language R


>  print.data.frame(foo,quote=T)
     x  ch   gr
1 "1" "a" "ab"
2 "2" "b" "ab"
3 "3"  NA "ab"
4 "4" "c" "ab"
5 "5" "d" "ab"

>  print.data.frame(foo,right=T)
   x   ch gr
1 1    a ab
2 2    b ab
3 3   <NA> ab
4 4    c ab
5 5    d ab

>  print.data.frame(foo,right=F)
   x ch   gr
1 1 a    ab
2 2 b    ab
3 3 <NA> ab
4 4 c    ab
5 5 d    ab

-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
--------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list