title: R How to replace value of a variable conditionally
body: <p>I am sure this question has been asked stacks of time but I couldn't find a solution.</p>
  
  <p>I am trying to conditionally replace the value of a second variable based on the value of first variable. Here is the data.</p>
  
  <pre><code> MAKE Continent
  1  HOLDEN        US
  2  HOLDEN        US
  3    FORD        US
  4    FORD        US
  
  if(gsample$MAKE == "HOLDEN") gsample$Continent = "AUS"
  </code></pre>
  
  <p>Warning message:</p>
  
  <pre><code>In if (gsample$MAKE == "HOLDEN") gsample$Continent = "AUS" :
    the condition has length &gt; 1 and only the first element will be used
  </code></pre>