Hello,

I'm trying to create a vector of r^2 values for using a function which I
will run in a "for" loop. Example:

per<-rnorm(100,.5,.2)^2
x<-rnorm(100,10,5)
y<-rnorm(100,20,5)
fr<-data.frame(x,y,per)

test<-rep(0,9)

plotter<-function(i){
temp.i<-fr[fr$per <=(i*.10),]
with(temp.i, plot(x, y, main=(i*.10),))
mod<-lm(y~x-1,data=temp.i)
r2<-summary(with(temp.i, lm(y~x)))$adj.r.squared
legend("bottomright", legend=signif(r2), col="black")
test[i]<-r2
print(r2)
abline(mod)
rm(temp.i)
rm(i)
rm(mod)
rm(r2)
}

test

Test comes up as the original vector of zeros. I know r2 is created for a
couple reasons (print works, and they show up on the graphs). Also, if I
run the function line by line with i assigned a number, test[i] is assigned
as it should be. However, if I call the function, plotter(i), test is not
modified, although the r^2 prints.

Mystified. What am I missing?

	[[alternative HTML version deleted]]

