title: which statement with multiple conditions to create new values in existing column
body: <p>I would like to modify an existing column with new additional values, based on some conditions. See the example below:</p>
  <p>dataset:</p>
  <pre><code>description &lt;- c(&quot;x value&quot;, &quot;y value&quot;, &quot;period 01-08-2019 t/m 31-08-2019 faktnr&quot;, &quot;x value&quot;, &quot;this is a sentence deb nr&quot;, &quot;x value&quot;, &quot;also a sentence debnr&quot;, &quot;deb nr&quot;, &quot;y value&quot;, &quot;y value&quot;)
  category_name &lt;- c(&quot;x&quot;, &quot;y&quot;, &quot;&quot;, &quot;x&quot;, &quot;&quot;, &quot;x&quot;, &quot;&quot;, &quot;&quot;, &quot;y&quot;, &quot;y&quot;)
  amount&lt;- c(-100, 200, -200, 10, 50, -3, -500, 100, 1, 1)
  FullData_Cleaned &lt;- cbind(description, category_name, amount)
  </code></pre>
  <p>What I would like to do is apply multiple conditions here based on the pattern, the amount and whether the row has already a value. If the conditions are met, I want to fill in the value &quot;credit&quot; (see below)</p>
  <p>Based on the abovementioned criteria, this should be the output:</p>
  <pre><code>(&quot;x&quot;, &quot;y&quot;, &quot;credit&quot;, &quot;x&quot;, &quot;&quot;, &quot;x&quot;, &quot;credit&quot;, &quot;&quot;, &quot;y&quot;, &quot;y&quot;)
  </code></pre>
  <p>This is my code:</p>
  <pre><code>patterns &lt;- c(&quot;debnr&quot;, &quot;deb nr&quot;, &quot;deb.nr&quot;,  &quot;fcnr&quot;, &quot;factnr&quot;, &quot;factno&quot;, &quot;faktnr&quot;)
  
  FullData_Cleaned$category_name &lt;- FullData_Cleaned[which(FullData_Cleaned$description %in% &quot;patterns&quot; &amp; FullData_Cleaned$amount &lt; 0 &amp; FullData_Cleaned$category_name == &quot;&quot;), ] &lt;- &quot;credit&quot;
  </code></pre>
  <p>However, this line of code fills the whole column with &quot;credit&quot; instead of only the blank values.</p>
  <p>Is there anyone that can help me?</p>