title: unexpected "{" error while trying to use for loop with an if statement
body: <p>I am trying to get the mean of the outer values of every possible triplet in a row with 15 values in total. I tried this and got the error.</p>
  
  <pre><code>for (i in 1:12){
    if (!is.na(data[1,i] &amp; data[1,i+1] &amp; data[1,i+2])){
      a[i] &lt;- apply(data[1,i],data[1,i+2],1,mean,na.rm=T)
    }
  }
  </code></pre>
  
  <p>I have looked everywhere but couldn't find a solution. What am I doing wrong here? Thanks for your help in advance!</p>