title: R how to subtract vector elements
body: <p>I have a numeric vector/array as below. After sorting in decreasing order, I want to have an array of differences between consecutive elements: I want to subtract 2nd element from 1st, 3rd element from nd etc...I can have n number of elements...how can I achieve the same?</p>
  
  <p>array of difference will have n-1 elements</p>
  
  <pre><code>a=c(2,3,5)
  a=sort(a,decreasing = TRUE)
  </code></pre>
  
  <p>In the above case array of differences will be (2,1)</p>