title: Tidyeval evaluate case_when
body: <p>Somewhat related to <a href="https://stackoverflow.com/questions/48023142/tidy-evaluation-programming-with-dplyrcase-when">Tidy evaluation programming with dplyr::case_when</a> and <a href="https://stackoverflow.com/questions/58418699/making-tidyeval-function-inside-case-when">Making tidyeval function inside case_when</a>, I want to create strings (using a shiny app) to be parsed later inside a <code>case_when</code> function. Here's an example:</p>
  
  <pre><code>library(tidyverse)
  
  # simulated shiny inputs
  new_column = sym("COL_NAME")
  
  number_of_categories = 3
  
  col1_text = "Big"
  col1_min = 7.0
  col1_max = 8.0
  
  col2_text = "Medium"
  col2_min = 5.0
  col2_max = 6.9
  
  col3_text = "Small"
  col3_max = 4.9
  col3_min = 4.0
  
  columninput = sym("Sepal.Length")
  </code></pre>
  
  <h1>DESIRED OUTPUT</h1>
  
  <pre><code>iris %&gt;%
    mutate(new_column =
             case_when(
               !!columninput &gt;= col1_min &amp; !!columninput &lt;= col1_max ~ col1_text,
               !!columninput  &gt;= col2_min &amp; !!columninput &lt;= col2_max ~ col2_text,
               !!columninput  &gt;= col3_min &amp; !!columninput &lt;= col3_max ~ col3_text
             )
    )
  </code></pre>
  
  <p>Because the only thing changing between functions is the index, I was thinking we can use the general pattern to create a string </p>
  
  <pre><code># create single string
  my_string &lt;-function(i) {
    paste0("!!", columninput, " &gt;= col", i, "_min &amp; ", "!!", columninput, " &lt;= col", i, "_max ~ col", i, "_text")
  }
  </code></pre>
  
  <p>Then repeat the string for the dynamic number of cases</p>
  
  <pre><code>mega_string &lt;- map_chr(1:number_of_categories, ~ my_string(.x))
  </code></pre>
  
  <h1>TODO:</h1>
  
  <p>This is the part I cant quite piece together: using those strings as the arguments within a <code>case_when</code>. </p>
  
  <pre><code># evaluate somehow?
  iris %&gt;%
    mutate(
      new_column = case_when(
        # tidyeval mega_string?
        paste(mega_string, collapse = "," )
        )
      )
  </code></pre>
  
  <p>Is this even the right approach? How else would you go about solving this - any help high level or otherwise is greatly appreciated!</p>