title: Computing deciles over calendar years and across different columns using R
body: <p>I have the following dataset that I created using dplyr and the function tbl_df():</p>
  
  <pre><code>date     X1    X2
  1  2001-01-31 4.698648 4.640957
  2  2001-02-28 4.491493 4.398382
  3  2001-03-30 4.101235 4.074065
  4  2001-04-30 4.072041 4.217999
  5  2001-05-31 3.856718 4.114061
  6  2001-06-29 3.909194 4.142691
  7  2001-07-31 3.489640 3.678374
  8  2001-08-31 3.327068 3.534823
  9  2001-09-28 2.476066 2.727257
  10 2001-10-31 2.015936 2.299102
  11 2001-11-30 2.127617 2.590702
  12 2001-12-31 2.162643 2.777744
  13 2002-01-31 2.221636 2.740961
  14 2002-02-28 2.276458 2.834494
  15 2002-03-28 2.861650 3.472853
  16 2002-04-30 2.402687 3.026207
  17 2002-05-31 2.426250 2.968679
  18 2002-06-28 2.045413 2.523772
  19 2002-07-31 1.468695 1.677434
  20 2002-08-30 1.707742 1.920101
  21 2002-09-30 1.449055 1.554702
  22 2002-10-31 1.350024 1.466806
  23 2002-11-29 1.541507 1.844471
  24 2002-12-31 1.208786 1.392031
  </code></pre>
  
  <p>I am interested in computing deciles for each year and each column. For example, the deciles of 2001 for X1, deciles of 2001 for X2, deciles of 2002 for X1, deciles of 2002 for X2 and so on if I have more years and more columns. I tried:</p>
  
  <p><code>quantile(x, prob = seq(0, 1, length = 11), type = 5)</code> or using <code>apply.yearly()</code> with the <code>quantile()</code> function and an xts object of x (my dataframe above) but none of them do what I actually need to compute. Your help will be appreciated.</p>