Re: [R] help with a for loop

2008-10-15 Thread jim holtman
I am not sure what you mean by "p is not updated". I took the basic outline you have and as you can see, p has the correct value after the loop. > p<-0.1 > n<-10 > result<-list() > while (p<=1) { + for (i in 1:n) { + result[[i]]<-p + p<-p+0.1 + print(p) + } + } [1]

[R] help with a for loop

2008-10-15 Thread Quan Li
Hi all, I am running OLS models with a power parameter: y=a+bx^p, and I want to iterate through p with a set increment. The function I constructed is something like below: test<-function(data, model,...){ f<-formula(model) #model="y~I(x^p)" p<-0.1 n<-10 result<-list() while (p<=1) { for (i in 1