[R] Slight problem in sort

Frank E Harrell Jr fharrell at virginia.edu
Thu Aug 7 03:37:35 CEST 2003


Thanks to all who clarified this for me.  The documentation is clear once I read it carefully.

Frank


On Wed, 06 Aug 2003 16:41:23 -0500
Marc Schwartz <MSchwartz at medanalytics.com> wrote:

> On Wed, 2003-08-06 at 16:38, Marc Schwartz wrote:
> > On Wed, 2003-08-06 at 16:21, Frank E Harrell Jr wrote:
> > > In
> > > 
> > > platform i686-pc-linux-gnu
> > > arch     i686             
> > > os       linux-gnu        
> > > system   i686, linux-gnu  
> > > status                    
> > > major    1                
> > > minor    7.1              
> > > year     2003             
> > > month    06               
> > > day      16               
> > > language R                
> > > 
> > > I get
> > > 
> > > > sort(c(3,1,NA))
> > > [1] 1 3
> > > 
> > > Shouldn't NAs be retained by default?
> > > 
> > > Thanks -Frank
> > 
> > 
> > Frank,
> > 
> > The default is to exclude NA's based upon the argument 'na.last = NA'. 
> > If you set the argument 'na.last' to either TRUE or FALSE, the NA's will
> > be kept and sorted either last or first respectively.
> > 
> > > sort(c(3,1,NA), na.last = TRUE)
> > [1]  1  3 NA
> > 
> > > sort(c(3,1,NA), na.last = LAST)
> > [1] NA  1  3
> > 
> > See ?sort
> > 
> > HTH,
> > 
> > Marc Schwartz
> 
> 
> Apologies. Bad copy on my part. The second example should be:
> 
> > sort(c(3,1,NA), na.last = FALSE)
> [1] NA  1  3
> 
> Marc
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help


---
Frank E Harrell Jr              Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat




More information about the R-help mailing list