title: How to replace 1 and 0 with male and female in R?
body: <p>I have a csv file contain a gender attribute with 1 = male and zero = female.
  I want to replace this value from 1 to male and 0 to female after reading the dataset using R.
  I tried this code but not working</p>
  <pre><code>df &lt;- read.csv('heart.csv')
  df[df$sex == 1] &lt;- &quot;male&quot;
  df[df$sex == 0] &lt;- &quot;female&quot;
  </code></pre>