I have a matrix whose columns are stock returns and whose rows are dates, which looks like this:
ES1.Index VG1.Index TY1.Comdty RX1.Comdty GC1.Comdty
1999-01-05 0.009828476 0.012405717 -0.003058466 -0.0003480884 -0.001723317
1999-01-06 0.021310816 0.027030061 0.001883240 0.0017392317 0.002425398
1999-01-07 -0.001952962 -0.016130850 -0.002826191 -0.0011591516 0.013425435
1999-01-08 0.007989946 -0.004071275 -0.005913678 0.0016224363 -0.001363540
I'd like to have a function that returns a matrix with the same column-names and row-names filled with 1s and 0s based on whether each observation within each row-vector belongs or not to some group within two given quantiles.
For example, I may want to divide each row vector into 3 groups and have 1s for all observations falling within the 2nd group and 0s elsewhere. The result being something looking like:
ES1.Index VG1.Index TY1.Comdty RX1.Comdty GC1.Comdty
1999-01-05 0 0 1 1 0
1999-01-06 1 0 0 1 0
1999-01-07 0 1 0 0 1
1999-01-08 0 0 1 0 1
(The 1s and 0s in my example are meant to be just a visual outcome, the numbers aren't accurate)
Which would be the least verbose way to get to that?