[Rd] Problem handling NA indexes for character matrixes (PR#1447)

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
10 Apr 2002 11:08:32 +0200


gregory_r_warnes@groton.pfizer.com writes:

> In a package I've been developing for manipulating genetic data I discovered
> a problem when indexing into character arrays using NA's:

> 	> cmat[ indvec,  ]
> 	     [,1] [,2]
> 	[1,] "a"  "c" 
> 	[2,] "b"  "d" 
> 	[3,] "NA" ""  
> 	> nmat[ indvec,  ]
> 	     [,1] [,2]
> 	[1,]    1    3
> 	[2,]    2    4
> 	[3,]   NA   NA

This seems to have vanished in R-1.5.0pre, likely as a (fortunate, if
unexpected) side effect of the character NA changes:

> cmat[ indvec,  ]
     [,1] [,2]
[1,] "a"  "c" 
[2,] "b"  "d" 
[3,] NA   NA  
> nmat[ indvec,  ]
     [,1] [,2]
[1,]    1    3
[2,]    2    4
[3,]   NA   NA

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._