FYI I have simplified the actual problem a lot
Say I have a matrix i.e. the dates and column/row names
2012-08-06 2012-08-13 2012-08-20 2012-08-27
2012-08-06 1.0 1.0 1.0 1.0
2012-08-13 1.0 1.0 1.0 1.0
2012-08-20 1.0 1.0 1.0 1.0
2012-08-27 1.0 1.0 1.0 1.0
and I have a reference date, where I want to pull out all the data which is greater or equal to this reference date. i.e. if the reference date is 2012-08-13 then I want this data:
2012-08-06 2012-08-13 2012-08-20 2012-08-27
2012-08-06
2012-08-13 1.0 1.0 1.0
2012-08-20 1.0
2012-08-27 1.0
I'm actually currently doing this by doing rows and columns separately and works fine for me i.e. using logic like data[rownames(data) < reference, colnames(data) == reference] to get columns and something similar to get the rows
However What I want is to have a reference lookup (so not just one value of multiple dates i.e. if I had two dates
reference = c("2012-08-13","2012-08-20")
Then the values I need to source need to be:
2012-08-06 2012-08-13 2012-08-20 2012-08-27
2012-08-06
2012-08-13 1.0 1.0 1.0
2012-08-20 1.0 1.0 1.0
2012-08-27 1.0 1.0
I want to eventually replace the 1.0's with something else where it meets this criteria
Can someone help me with referencing rows/column names to a vector of lookups? What my end goal is, is to actually use the rows/columns that I have kept as 1.0 to replace these numbers with some other calculated field (in the original matrix)
Thanks