[tech-spec] Re: loop return vector
- From: James Sogi <jsogi@xxxxxxxxxxxxx>
- To: tech-spec@xxxxxxxxxxxxx
- Date: Sun, 27 Feb 2005 12:44:58 -1000
Kudos to Tim. Good stuff.
Requesting help on ?"for" loop question (R 2.0 on XP), please.
for(i in 1:5) a <- (i > 2)
> a
[1] TRUE
> print(a)
[1] TRUE
#how do I get it to return entire vector, not just 1? What am I missing
here?
# print returns vector, but how can I assign the entire vector for
later subsetting/looping?
> for(i in 1:5) print(i)
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
> for(i in 1:5) print(i > 2)
[1] FALSE
[1] FALSE
[1] TRUE
[1] TRUE
[1] TRUE
>
Thanks.
Jim
Other related posts: