title: Replace text values in a vector
body: <p>Here's my data : </p>
  
  <pre><code>dataset &lt;- c("h", "H", "homme", "masculin", "f", "femme", "épouse")
  </code></pre>
  
  <p>How can I replace text values of the vector like :  </p>
  
  <ul>
  <li>"femme" -> "f"  </li>
  <li>"épouse" ->"f"  </li>
  <li>"Homme"-> "h"  </li>
  <li>"masculin" -> "h" </li>
  </ul>
  
  <p>What I tried for  "femme" -> "f"</p>
  
  <pre><code>test_out &lt;- sapply(dataset, switch,
           "f"="femme")
  test_out 
  </code></pre>
  
  <p>Expected result :</p>
  
  <pre><code>  "h"        "h"        "h"    "masculin" "f"        "f"    "f"  
  </code></pre>