title: get a derivative by knowing two numeric vectors
body: <p>I know two vectors x and y, how can I calculate derivatives of y with respect to x in R ?</p>
  
  <pre><code>x&lt;-rnorm(1000)
  y&lt;-x^2+x
  </code></pre>
  
  <p>I want to caculate derivative of y with respect to x: dy/dx; suppose I don't know the underlying function between x and y. There can be a value in derivative scale corresponding to each x. </p>