[R] if else statements in R

2003-06-30 Thread Michael Rennie
Hi, there I am a grad student struggling to get my syntax right in a model I am building in R. I am trying to specify a variable,W, in a loop, such that on the first iteration, it is equal to Wo, my starting value, which I have already specified with Wo-9.2 On any other iteration other

[R] if else statements in R

2003-06-30 Thread Michael Rennie
Hi, there I am a grad student struggling to get my syntax right in a model I am building in R. I am trying to specify a variable,W, in a loop, such that on the first iteration, it is equal to Wo, my starting value, which I have already specified with Wo-9.2 On any other iteration other

Re: [R] if else statements in R

2003-06-30 Thread Timur Elzhov
On Mon, Jun 30, 2003 at 11:21:52AM -0400, Michael Rennie wrote: W- function(w) { if (comp[i,1]=1) W[i]-Wo else == is comparison operator, but = is assignment one. This code also doesn't work: x - 0 if (x = 1) Error: syntax error But this works: if (x == 1) + Chack also help(==), help(=)

Re: [R] if else statements in R

2003-06-30 Thread Andrew Perrin
This is untested, so try it first, but my approach would be: W- function(w) { W[i]-ifelse(comp[i,1]==1, Wo, (work[i-1,5]work[i-1,13]*/Ef)) } Best, Andy Perrin -- Andrew J Perrin - http://www.unc.edu/~aperrin Assistant Professor

Re: [R] if else statements in R

2003-06-30 Thread kjetil brinchmann halvorsen
On 30 Jun 2003 at 11:24, Michael Rennie wrote: Hola! Hi, there I am a grad student struggling to get my syntax right in a model I am building in R. I am trying to specify a variable,W, in a loop, such that on the first iteration, it is equal to Wo, my starting value, which I have