Dear all, 
this is my first post and I´m very new at R, I don´t know if somebody can
help with an issue.
I´m doing some exercices and I don´t know if for example I can convert this
for in an operation with vectors:

for (i in 2:n){
        if (ES[i-1]==0 && sprd[i-1]>mediaSDP[i-1]  && sprd[i]<=mediaSDP[i]) 
{ES[i]
<- -1} else
        if((ES[i-1]==-1 || ES[i-1]==-15) && sprd[i]>media[i]) {ES[i] <- -15} 
else
        if((ES[i-1]==-1 || ES[i-1]==-15) && sprd[i]<=media[i]) {ES[i] <- -17} 
else
        if(ES[i-1]==0 && sprd[i-1]<mediaSDN[i-1] &amp;&amp; 
sprd[i]>=mediaSDN[i])
{ES[i] <- 1} else
        if((ES[i-1]==1 || ES[i-1]==15)&& sprd[i]<media[i]) {ES[i] &lt;- 15} else
        if((ES[i-1]==1 || ES[i-1]==15)&amp;&amp; sprd[i]>=media[i]) {ES[i] <- 
17}
else {ES[i] <-0}
}

Thanks a lot!!

--
View this message in context: 
http://r.789695.n4.nabble.com/Loops-and-vector-operations-tp4240434p4240434.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to