On 24/02/2010 4:31 PM, Georg Ehret wrote:
Dear R communtiy,
   I do not understand why this does not work...:

> betaS$SBP
[1]  0.03274 -0.04216 -0.08986 -0.45980  0.60320 -0.63070 -0.05682  0.20130
> t<-c("betaS$SBP")
> t
[1] "betaS$SBP"
> get(t)
Error in get(t) : object 'betaS$SBP' not found
The problem is that betaS$SBP is an expression that extracts a component of the betaS object, it's not the name of an object. get() only gets single objects, it doesn't evaluate expressions. You need something like

eval(parse(text=t))

to get what you want.

Duncan Murdoch

[I am trying to use the variable "t" in a loop to call many different
objects, but the pasting together did not work and this simple example does
not neither...]

Thank you and best regards, Georg.
*******************
Georg Ehret
JHU
Baltimore

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to