title: median(x) is does not correctly return the middle value of x
body: <p>I have a really frustrating problem with <strong>R</strong>. What I want is fairly easy: I have a vector of numeric values (without <code>NA</code>) and want to calculate the median value. To perform this easy task I wrote the following line:</p>
  <pre><code>#returning 4.0585
  medianOfVector &lt;- median(dataFrame$colname)
  </code></pre>
  <p>However, I had to realize that the value this line returns does not match with the number I get when perorming the following line:</p>
  <pre><code>#returning 1048
  lengthOfVector &lt;- length(dataFrame$colname)
  #returning 4.1355
  medianOfVector2 &lt;- (dataFrame$colname[524]+dataFrame$colname[525])/2
  </code></pre>
  <p>As I understand it right the <code>median()</code> function should return the value that is exactly in the middle of the vector (or the mean of the two values in the middle if the length of the vector is even), but this seems not to be the case. Unfortunately I can't trace the steps the <code>median()</code> function is doing, so I can't solve the problem.
  Can anyone help here, or tell me where I may have made a mistake?</p>