[R] "get" problem
David Winsemius
dwinsemius at comcast.net
Wed Feb 24 22:46:15 CET 2010
On Feb 24, 2010, at 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
A couple of different ways of passing multi-element objects to loops:
> tt <- scan()
1: 0.03274 -0.04216 -0.08986 -0.45980 0.60320 -0.63070 -0.05682
0.20130
9:
Read 8 items
> tt
[1] 0.03274 -0.04216 -0.08986 -0.45980 0.60320 -0.63070 -0.05682
0.20130
> for (xi in seq(tt)) print(xi)
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7
[1] 8
> for (xi in seq(tt)) print(tt[xi])
[1] 0.03274
[1] -0.04216
[1] -0.08986
[1] -0.4598
[1] 0.6032
[1] -0.6307
[1] -0.05682
[1] 0.2013
> beta <-list()
> beta$SBP <- tt
> beta["SBP"]
$SBP
[1] 0.03274 -0.04216 -0.08986 -0.45980 0.60320 -0.63070 -0.05682
0.20130
> for (xi in seq_along(beta$SBP) ) print(xi)
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7
[1] 8
> for (xi in beta$SBP) print(xi)
[1] 0.03274
[1] -0.04216
[1] -0.08986
[1] -0.4598
[1] 0.6032
[1] -0.6307
[1] -0.05682
[1] 0.2013
--
David.
>
>
> [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 at 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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list