title: Dplyr mutate many columns with each new column conditional on two columns
body: <p>My data frame is like the simple one below with many more columns and rows.</p>
  
  <p>My goal is to add a new column  for every "model" based on some ifelse() output using the matching <em>pval</em> and <em>value_IC</em> column.</p>
  
  <p>Here, models are linear, beta and emax. </p>
  
  <p>The closest problem I have found so far was here</p>
  
  <p><a href="https://community.rstudio.com/t/how-to-mutate-at-mutate-if-multiple-columns-using-condition-on-other-column-outside-vars-dplyr/17506/2" rel="nofollow noreferrer">https://community.rstudio.com/t/how-to-mutate-at-mutate-if-multiple-columns-using-condition-on-other-column-outside-vars-dplyr/17506/2</a></p>
  
  <p>where there is always the same "second" column used.</p>
  
  <pre><code>data &lt;- data.frame(pval.linear.orig = c(0.01, 0.06, 0.02),
                     pval.beta.orig = c(0.06, 0.02, 0.01),
                     pval.emax.orig = c(0.03, 0.01, 0.07),
                     value_IC.linear.orig = c(-5, NA, -4),
                     value_IC.beta.orig = c(NA, NA, -10),
                     value_IC.emax.orig = c(NA, -11, NA))
  
    pval.linear.orig pval.beta.orig pval.emax.orig value_IC.linear.orig value_IC.beta.orig value_IC.emax.orig
  1             0.01           0.06           0.03                   -5                 NA                 NA
  2             0.06           0.02           0.01                   NA                 NA                -11
  3             0.02           0.01           0.07                   -4                -10                 NA
  
  </code></pre>
  
  <p>If I only wanted it for one model, let's say beta, I would do this:</p>
  
  <pre><code>library(dplyr)
  data_new &lt;- data %&gt;% mutate(conv.beta.orig = case_when(
    pval.beta.orig &gt; 0.025~ NA,
    pval.beta.orig &lt;= 0.025 &amp; !(is.na(value_IC.beta.orig))  ~ TRUE,
    pval.beta.orig &lt;= 0.025 &amp; is.na(value_IC.beta.orig) ~ FALSE)) 
  
  data_new
  
    pval.linear.orig pval.beta.orig pval.emax.orig value_IC.linear.orig value_IC.beta.orig value_IC.emax.orig conv.beta.orig
  1             0.01           0.06           0.03                   -5                 NA                 NA             NA
  2             0.06           0.02           0.01                   NA                 NA                -11          FALSE
  3             0.02           0.01           0.07                   -4                -10                 NA           TRUE
  </code></pre>
  
  <p>to get the <em>conv.beta.orig</em> column. The column name does not have to be exactly in this format. </p>
  
  <p>My problem now is to do so with all models I have each using the pval.MODEL.orig and value_IC.MODEL.orig column as above.</p>
  
  <p>Thank you very much for your help!
  This is the first question I ever posted, let me now if I should reformulate something / missed something or didn't spot this problem in case it already exists / etc.</p>