title: How to conditionally highlight points in ggplot2 facet plots - mapping color to column
body: <p>In the following example I create two series of points and plot them using <code>ggplot2</code>. I also highlight several points based on their values</p>
  
  <pre><code>library(ggplot2)
  x &lt;- seq(0, 6, .5)
  y.a &lt;- .1 * x -.1
  y.b &lt;- sin(x)
  df &lt;- data.frame(x=x, y=y.a, case='a')
  df &lt;- rbind(df, data.frame(x=x, y=y.b, case='b'))
  print(ggplot(df) + geom_point(aes(x, y), color=ifelse(df$y&lt;0, 'red', 'black')))
  </code></pre>
  
  <p>And here is the result</p>
  
  <p><img src="https://i.stack.imgur.com/vz2j2.png" alt="First result"></p>
  
  <p>Now I want to separate the two <code>case</code>s into two facets, keeping the highlighting scheme</p>
  
  <pre><code>&gt; print(ggplot(df) + geom_point(aes(x, y), color=ifelse(df$y&lt;0, 'red', 'black')) + facet_grid(case ~. ,))
  Error: Incompatible lengths for set aesthetics: colour
  </code></pre>
  
  <p>How can this be acheived?</p>