[R] (no subject)

Bob O'Hara rni.boh at gmail.com
Thu Oct 13 10:29:06 CEST 2016


I've just come across an odd problem with sorting in ls(): it doesn't
seem to order the object names correctly. If I do the following, the
order isn't what I expect:

> ls(sorted=TRUE)
 [1] "AridData"          "AridDataToBUGS"    "Arid.df"
"Arid.hpd"          "AridPrecip.sd"     "Break.df"
 [7] "Break.hpd"         "Cols"              "Data"
"DataFrames"        "DataToBUGS"        "DataToBUGS.nonlog"
[13] "FitBRugs"          "Fixed.df"          "Fixed.hpd"
"FormatData"        "GetCol"            "GetHPD"
[19] "GetMCMC"           "GetRow"            "HPDIs"
"Int.alpha12"       "Int.alpha21"       "ModisData"
[25] "ModisDataToBUGS"   "Modis.df"          "ModisFixed.df"
"ModisFixed.hpd"    "Modis.hpd"         "ModisPrecip.sd"
[31] "ModisShrink.df"    "ModisShrink.hpd"   "ModisYears"
"OrigData"          "OrigDataToBUGS"    "Orig.df"
[37] "Orig.hpd"          "OrigPrecip.sd"     "OrigYears"
"PlotChecks"        "PlotEff"           "plothpd"
[43] "ProvinceNames"     "ResNames"          "ResNamesOrder"
"Shrink.df"         "Shrink.hpd"        "SimInits"

Specifically, the Modis* objects are sorted like this:

> ls(sorted=TRUE)[26:30]
[1] "Modis.df"       "ModisFixed.df"  "ModisFixed.hpd" "Modis.hpd"
 "ModisPrecip.sd"

With Modis.* coming both before and after ModisF*. I can't see why
there would be any odd problems with character sets changing (this was
all done on a single computer with no weird locale switching), and the
objects are all created within a single R session:

> sessionInfo()
R version 3.2.5 (2016-04-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
LC_TIME=en_GB.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_US.UTF-8
LC_PAPER=en_GB.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] MCMCglmm_2.22.1    ape_3.5            Matrix_1.2-7.1
RColorBrewer_1.1-2 plyr_1.8.4         coda_0.18-1

loaded via a namespace (and not attached):
[1] cubature_1.1-2  corpcor_1.6.8   tools_3.2.5     Rcpp_0.12.7
nlme_3.1-128    grid_3.2.5      knitr_1.14
[8] tensorA_0.36    lattice_0.20-34

Can anyone explain what's going on?

Bob

-- 
Bob O'Hara

Biodiversity and Climate Research Centre
Senckenberganlage 25
D-60325 Frankfurt am Main,
Germany

Tel: +49 69 798 40226
Mobile: +49 1515 888 5440
WWW:   http://www.bik-f.de/root/index.php?page_id=219
Blog: http://occamstypewriter.org/boboh/
Journal of Negative Results - EEB: www.jnr-eeb.org



More information about the R-help mailing list