R-alpha: expression(..) objects -- c(ex1, ex2) `fails'
Peter Dalgaard BSA
p.dalgaard@kubism.ku.dk
03 Nov 1997 19:27:53 +0100
Martin Maechler <maechler@stat.math.ethz.ch> writes:
[I've taken out the ">" citation symbols to allow cut and paste]
##-- `Simple' length--1 expressions:
ex1 <- expression(hat(beta) == (X^t * X)^{-1} * X^t * y)
ex2 <- expression(bar(x) == sum(over(x[i], n), i==1, n))
##-- A length--2 expression:
ex12 <- expression(bar(x) == sum(over(x[i], n), i==1, n),
hat(x) == median(x[i], i==1,n))
##please avoid TABS, Martin. It confuses readline...
> ###-> How could I take ex1, ex2 and "concat" them to an expression
> ### of length 2 ?
#Heh. One would at least expect
l<-NULL
l[[1]]<-ex1[[1]]
l[[2]]<-ex2[[1]]
#to be a list of calls, which by definition is what an expression is,
#so you'd only need to change the mode, but:
mode(e)<-"expression"
e
# expression(list(hat(beta) == (X^t * X)^{
# -1
# } * X^t * y, bar(x) == sum(over(x[i], n), i == 1, n)))
#(Why does it deparse in that strange way, BTW?)
#Also, textual representations of length-2 expressions is acting up:
deparse(ex12)
#[1] "bar(x) == sum(over(x[i], n), i == 1, n)"
str(ex12)
# bar(x) == sum(over(x[i], n), i == 1, n)
dput(ex12)
# bar(x) == sum(over(x[i], n), i == 1, n)
deparse(ex12[[2]])
# [1] "hat(x) == median(x[i], i == 1, n)"
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=