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 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
Frank E Harrell Jr <fharrell at virginia.edu> writes:> I get > > > sort(c(3,1,NA)) > [1] 1 3 > > Shouldn't NAs be retained by default?Not according to the documentation... sort(x, partial = NULL, na.last = NA, decreasing = FALSE, method = c("shell", "quick"), index.return = FALSE) na.last: for controlling the treatment of `NA's. If `TRUE', missing values in the data are put last; if `FALSE', they are put first; if `NA', they are removed. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
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 -FrankFrank, 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
Frank E Harrell Jr wrote:>>sort(c(3,1,NA)) > > [1] 1 3 > > Shouldn't NAs be retained by default?help(sort) sort(c(3,1,NA),na.last=TRUE) Cheers Jason -- Indigo Industrial Controls Ltd. 64-21-343-545 jasont at indigoindustrial.co.nz