On Mon, 17 Jul 2006, [EMAIL PROTECTED] wrote:

> Full_Name: Jiancang Zhuang
> Version: 2.3.0
> OS: Windows XP, BSD, Linux
> Submission from: (NULL) (130.195.2.100)
> 
> 
> > a<-matrix(scan(), ncol=3, byrow=T)
> 1: 6 NA 4 
> 4: 5 3 6
> 7: 8 2 9 
> 10: 3 6 NA
> 13: 
> Read 12 items
> > a
>      [,1] [,2] [,3]
> [1,]    6   NA    4
> [2,]    5    3    6
> [3,]    8    2    9
> [4,]    3    6   NA
> > a[a[,2]>2,]
>      [,1] [,2] [,3]
> [1,]   NA   NA   NA
> [2,]    5    3    6
> [3,]    3    6   NA
> 
> We may hope the first row of A removed or keep the same. However, R keeps the
> first row and changes all the value in that row into NA.

What `we may hope' is not relevant to a bug report.  R works as 
documented.

In your example a[,2] is c(NA, 3, 2, 6) and so the condition is
c(NA, TRUE, FALSE, TRUE).  You do not know if the first row should be 
included or not (the information is missing), and so the correct answer is 
NA.

One reference is the R Language Definitions (R-lang) which says

Indexing with a missing (i.e.@: @code{NA}) value give an @code{NA}
result.  This rule applies also to the case of logical indexing,
i.e.@: the elements of @code{x} that have an @code{NA} selector in
@code{i} get included in the result, but their value will be @code{NA}.

Please do study the R FAQ and not misuse R-bugs to report documented 
behaviour.

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to