title: How to correctly pass inequality or range to dplyr::case_when
body: <p>I am unsuccessfully trying to create levels of a given variable using dplyr::case_when involving intervals. </p>
  
  <p><strong>#preparing sample data</strong>  </p>
  
  <pre><code>mtmodel &lt;- lm(mpg ~ wt, data = mtcars)
  mtcars$Low &lt;- predict(mtmodel, newdata = mtcars, interval = "confidence")[,2]
  mtcars$High &lt;- predict(mtmodel, newdata = mtcars, interval = "confidence")[,3]
  mtcars$Mean &lt;- predict(mtmodel, newdata = mtcars, interval = "confidence")[,1]
  new_mtcars&lt;-gather(mtcars, "Variable", "value", Low:Mean)
  </code></pre>
  
  <p><strong>#creating groups using dplyr::case_when</strong></p>
  
  <pre><code>#does not work
  library(tidyverse)
  new_new_mtcars&lt;-new_mtcars %&gt;%
         mutate(grouping = case_when (
         min(new_mtcars$wt) &lt;= new_mtcars$wt&lt;= mean(new_mtcars$wt)+0.99 ~ "group1",
         new_mtcars$wt &gt;= max(new_mtcars$wt) - 0.5  ~ "group2"))
  </code></pre>
  
  <p><strong>#R returns this error message and does not do the job as intended</strong></p>
  
  <pre><code>Error: unexpected '&lt;=' in:
  "           mutate(grouping = case_when (
                 min(new_mtcars$wt) &lt;= new_mtcars$wt&lt;="
  
  Error: unexpected ')' in "           
  new_mtcars$wt &gt;= max(new_mtcars$wt) - 0.5  ~ "group2")"
  </code></pre>