From Bernhard_Pfaff at fra.invesco.com  Fri Oct 27 12:46:56 2006
From: Bernhard_Pfaff at fra.invesco.com (Pfaff, Bernhard Dr.)
Date: Fri, 27 Oct 2006 11:46:56 +0100
Subject: [Rd] all.names() and all.vars(): sorting order of functions' return
	vector
Message-ID: <E4A9111DA23BA048B9A46686BF727CF461BDD7@DEFRAXMB01.corp.amvescap.net>

Dear list-subscriber,

in the process of writing a general code snippet to extract coefficients
in an expression (in the example below: 0.5 and -0.7), I stumbled over
the following peculiar (at least peculiar to me:-) ) sorting behaviour
of the function all.names():

> expr1 <- expression(x3 = 0.5 * x1 - 0.7 * x2)
> all.names(expr1)
[1] "-"  "*"  "x1" "*"  "x2"
> all.vars(expr1)
[1] "x1" "x2"
> expr2 <- expression(x3 <-  0.5 * x1 - 0.7 * x2)
> all.names(expr2)
[1] "<-" "x3" "-"  "*"  "x1" "*"  "x2"
> all.vars(expr2)
[1] "x3" "x1" "x2"
> expr3 <- expression(x3 ~  0.5 * x1 - 0.7 * x2)
> all.names(expr3)
[1] "~"  "x3" "-"  "*"  "x1" "*"  "x2"
> all.vars(expr3)
[1] "x3" "x1" "x2"
> 

For all.names(expr2) and all.names(expr3) I would expect something like:

[1] "x3" "<-" "*" "x1" "-" "*" "x2"

[1] "x3" "~" "*" "x1" "-" "*" "x2"

To which kind of rule is the sorting order in the returned character
vector produced? Any help or pointers is much appreciated.

Best,
Bernhard


> sessionInfo()
R version 2.5.0 Under development (unstable) (2006-10-10 r39600) 
i386-pc-mingw32 

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=
German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

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

[7] "base"     

other attached packages:
    nlme fortunes 
"3.1-77"  "1.3-2" 
> 
*****************************************************************
Confidentiality Note: The information contained in this mess...{{dropped}}




[Rd] all.names() and all.vars(): sorting order of functions' return vector
Pfaff, Bernhard Dr.