I have a matrix of costs I'd like to discount according to discount rate, x. Each column is a unique disease state and each row is a unique year. Currently I'm working off of this code:
((medexpCommercial)/((1 + dr)^as.integer(rownames(medexpCommercial))))
The latter always works, while the first is buggy. What if you have row names like "A", "B", "C"? Even if you have row names like "1", "3", "2", but look, they are not sorted (this is particularly the case after some row reordering of your data frame).