title: Error message in R: replacement has (x) rows, data has (y)
body: <p>I am getting an error message when I am attempting to change the name of a data element in a column. This is the structure of the data frame I am using.</p>
  
  <pre><code>'data.frame':   2070 obs. of  7 variables:
   $ Period: Factor w/ 188 levels "1 v 1","10 v 10",..: 158 158 158 158 158 158 158 158 158 158 ...
   $ Dist  : num  7548 7421 9891 8769 10575 ...
   $ HIR   : num  2676 2286 3299 2455 3465 ...
   $ V6    : num  66.2 18.5 81 40 275.1 ...
   $ Date  : Factor w/ 107 levels "1/3/17","1/4/17",..: 38 38 38 38 38 38 38 38 38 38 ...
   $ Type  : Factor w/ 28 levels "Captain's Run",..: 5 5 5 5 5 5 5 5 5 5 ...
   $ Day   : Factor w/ 8 levels "Friday","Monday",..: 1 1 1 1 1 1 1 1 1 1 ...
  #&gt; Error: &lt;text&gt;:1:22: unexpected symbol
  #&gt; 1: 'data.frame':   2070 obs.
  #&gt;                          ^
  ```
  </code></pre>
  
  <p>I wish to change the value <code>Main Session</code> in <code>db$Type</code> to <code>Main Training</code> so I can match this data frame to another I'm using. I'm using the code below to try and do this.</p>
  
  <pre><code>class(db$Type)
  db$Type &lt;- as.character(db$Type)
  db$Type["Main Session"] = "Main Training"
  </code></pre>
  
  <p>I am getting this error message when I attempt to run the piece of code.</p>
  
  <pre><code>db$Type["Main Session"] = "Main Training"
  Error in `$&lt;-.data.frame`(`*tmp*`, Type, value = c("Main Session", "Main Session",  : 
    replacement has 2071 rows, data has 2070
  #&gt; Error: &lt;text&gt;:2:7: unexpected 'in'
  #&gt; 1: db$Type["Main Session"] = "Main Training"
  #&gt; 2: Error in
  #&gt;          ^
  </code></pre>
  
  
  
  <p>Being relatively new to R, is there anything I am missing in my code that could resolve this issue? Any suggestions will be greatly appreciated. Thank you.</p>