title: rename the category of variable in R
body: <p>I have text variable  <code>X1</code>. It takes value <code>A,B,C,D</code>. I need to rename category D to F. So in output i expect <code>A,B,C,F</code>
  How can i  do it?
  here my dataset</p>
  
  <pre><code>mydat=structure(list(x1 = structure(1:4, .Label = c("a", "b", "c", 
  "d"), class = "factor"), x2 = c(1L, 1L, 1L, 1L), x3 = c(2L, 2L, 
  2L, 2L)), .Names = c("x1", "x2", "x3"), class = "data.frame", row.names = c(NA, 
  -4L))
  </code></pre>