[Rd] all.names() and all.vars(): sorting order of functions' return vector
Pfaff, Bernhard Dr.
Bernhard_Pfaff at fra.invesco.com
Fri Oct 27 12:46:56 CEST 2006
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}}
More information about the R-devel
mailing list