[R] Posterior use of iterations output in a for() loop
Duarte Viana
viana.sptd at gmail.com
Tue Aug 18 17:37:40 CEST 2009
Dear all,
Please apologyse if this is too simple. I am a beginner.
I am trying to extract the resulting output of each iteration in a
for() loop in order to concatenate them and make an histogram out of
that.
Example:
a<-c(1,2,3,3,3,4,6,7,7,8)
b<-c(5,8)
# function to obtain 2 (length of "a") vectors, each corresponding to
b<=a (b<=5 and b<=8)
fun<-function(x,y){
for(y in y){
cat(y,":",x[x<=y],"\n")
}
}
fun(a,b) #result
Question: I want to concatenate the resulting vectors (the "5" and the
"9") to make an histogram. I could just copy and paste them, but I
want to do this with thousands of vectors (each one resulting from an
iteration, which can be a vector of potential enormous length).
I would really appreciate some help.
Thanks,
Duarte Viana
More information about the R-help
mailing list