mardi 22 octobre 2019

Is there a way to subscribe two commands in R?

Is there a way to subscribe two commands in R?

For example, there are two formulas for calculating a.

a <- d + 1

a <- e + 3

In a loop, At first, I use the first formula. When a condition satisfied, I want to use the second formula and don't use the first formula in r.

Like this artificial example:

beta <- 0.1

j <- 2

repeat{

s <- j * 5

beta[j] <- s + 2                # the first formula

diff <- beta[j] - beta[j - 1]

if(diff < 0.001) beta[j] <- s * 100  # the second formula

if(diff < 0.00001) 
{
break
       }
j <- j + 1
}

Is there a way to inactive the first formula and use second formula in the loop?

Aucun commentaire:

Enregistrer un commentaire