title: Remove alphanumeric and special character from a string in R
body: <p>mydata.dt=</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">Candidate.index</th>
  <th style="text-align: center;">Score</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">1</td>
  <td style="text-align: center;">0: most of the time (5-7days/week)</td>
  </tr>
  <tr>
  <td style="text-align: center;">2</td>
  <td style="text-align: center;">0: most of the time (5-7days/week)</td>
  </tr>
  <tr>
  <td style="text-align: center;">3</td>
  <td style="text-align: center;">NA</td>
  </tr>
  <tr>
  <td style="text-align: center;">4</td>
  <td style="text-align: center;">3 : less likely (less than 1 per day)</td>
  </tr>
  <tr>
  <td style="text-align: center;">5</td>
  <td style="text-align: center;">1: a moderate amount of time (3-4 days per week)</td>
  </tr>
  <tr>
  <td style="text-align: center;">6</td>
  <td style="text-align: center;">0: most of the time (5-7days per week)</td>
  </tr>
  <tr>
  <td style="text-align: center;">7</td>
  <td style="text-align: center;">2:    some times  (3-4 days per week)</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Output desired---</p>
  <p>mydata.dt=</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">Candidate.index</th>
  <th style="text-align: center;">Score</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">1</td>
  <td style="text-align: center;">0</td>
  </tr>
  <tr>
  <td style="text-align: center;">2</td>
  <td style="text-align: center;">0</td>
  </tr>
  <tr>
  <td style="text-align: center;">3</td>
  <td style="text-align: center;">NA</td>
  </tr>
  <tr>
  <td style="text-align: center;">4</td>
  <td style="text-align: center;">3</td>
  </tr>
  <tr>
  <td style="text-align: center;">5</td>
  <td style="text-align: center;">1</td>
  </tr>
  <tr>
  <td style="text-align: center;">6</td>
  <td style="text-align: center;">0</td>
  </tr>
  <tr>
  <td style="text-align: center;">7</td>
  <td style="text-align: center;">2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Code used:
  The observations were in factors so converted them to character first--
  <code>mydata.dt [, Score := as.character(Score)]</code>
  Then tried to remove the description of scores using this code---
  <code>mydata.dt$Score &lt;- as.integer(gsub('[a-zA-Z]', '', mydata.dt$Score))</code></p>
  <p>this gives a <em>Warning message:
  In eval(ei, envir) : NAs introduced by coercion.</em>
  Output all the observations in Score column were converted to <em>NA</em></p>
  <p>This may be a repeated question, I tried a lot using the codes available in the previous thread but it doesn't seem t work well for me. Please help.</p>