title: IF else statement throws an error in R
body: <p>I am novice in R. I am trying to assign some values to column based on if else statement. But it keeps throwing me error. Could some help me understand what the error is for?</p>
  
  <p>Code:</p>
  
  <pre><code>if (REAR[mean &lt; (-2) &amp; mean &gt; 2,]) {
    REAR$EXCEPTION_1&lt;-1; REAR$EXCEPTION_2&lt;-0
  } else  if(REAR[!(mean &lt; (-2) &amp; mean &gt; 2) &amp; deviation &gt; 1.5,])  {
    REAR$EXCEPTION_1&lt;-0; REAR$EXCEPTION_2&lt;-1
  } else {
    REAR$EXCEPTION_1&lt;-0; REAR$EXCEPTION_2&lt;-0
  }
  
  
  Error:
  Error:
  Error in mean &lt; (-5) : 
    comparison (3) is possible only for atomic and list types
  </code></pre>
  
  <p>Sample data:</p>
  
  <pre><code>dput(head(REAR))
  
  structure(list(TIMESTAMP = structure(list(c(0, 0, 0, 
  0, 0, 0), c(45L, 0L, 15L, 30L, 45L, 0L), c(17L, 18L, 18L, 18L, 
  18L, 19L), c(5L, 5L, 5L, 5L, 5L, 5L), c(7L, 7L, 7L, 7L, 7L, 7L
  ), c(114L, 114L, 114L, 114L, 114L, 114L), c(2L, 2L, 2L, 2L, 2L, 
  2L), c(216L, 216L, 216L, 216L, 216L, 216L), c(0L, 0L, 0L, 0L, 
  0L, 0L), c("IST", "IST", "IST", "IST", "IST", "IST"), c(NA_integer_, 
  NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_
  )), class = c("POSIXlt", "POSIXt")), ID = c(28808, 28808, 
  28808, 28808, 28808, 28808), CONNECTION= c("UP", "UP", 
  "UP", "UP", "UP", "UP"), ACTIVE = c(68.814, 68.814, 
  68.814, 68.814, 68.814, 68.814), SET = c(70, 
  70, 70, 70, 70, 70), MODE = c("Cool", "Cool", "Cool", 
  "Cool", "Cool", "Cool"), STATUS = c("Occupied", "Occupied", 
  "Occupied", "Occupied", "Occupied", "Occupied"), KNOB= c("On", 
  "On", "On", "On", "On", "On"), loopN = c(140805L, 140805L, 140805L, 
  140805L, 140805L, 140805L), timediff = c(15, 15, 15, 15, 15, 
  15), diff= c(-1.18600000000001, -1.18600000000001, 
  -1.18600000000001, -1.18600000000001, -1.18600000000001, -1.18600000000001
  ), mean = c(-1.67920000000001, -1.67920000000001, -1.67920000000001, 
  -1.67920000000001, -1.67920000000001, -1.67920000000001), deviation= c(0.553944943112579, 
  0.553944943112579, 0.553944943112579, 0.553944943112579, 0.553944943112579, 
  0.553944943112579), EXCEPTION_1 = c(0, 0, 0, 0, 0, 
  0), EXCEPTION_2 = c(0, 0, 0, 0, 0, 0)), .Names = c("TIMESTAMP", 
  "ID", "CONNECTION", "ACTIVE ", "SET", 
  "MODE", "STATUS", "KNOB", 
  "loopN", "timediff", "diff", "mean", "deviation", 
  "EXCEPTION_1", "EXCEPTION_2"), row.names = 764:769, class = "data.frame")
  </code></pre>