I have a table in following format(column headers as well as From/To refer to months)
The columns refer to distinct numerical months(which will always be a multiple of 12) for which I am providing year by year value.
For the periods where it doesn't make sense (eg month 25 onwards for a 20 month column), I want to blackout the fields. So I wanna arrive from :

to this:
Here's the code that's helping me get started on this but I'm not sure for a cell how can I refer to its column name, as well as respective 'To' column
library(dplyr)
library(rhandsontable)
colheaders<-c(24,36,48,60)
df<-matrix(0,nrow = ceiling(max(colheaders)/12), ncol=length(colheaders)+2) %>%
data.frame() %>%
`colnames<-`(c('From','To',colheaders)) %>%
mutate(From=c(1:ceiling(max(colheaders)/12))*12-11) %>%
mutate(To=c(1:ceiling(max(colheaders)/12))*12)
rhandsontable(df) %>%
hot_col(as.character(colheaders), format = "0.00%") %>%
hot_col(c("From","To"), format = "0", readOnly = T) %>%
hot_cols(renderer = "
function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.NumericRenderer.apply(this, arguments);
if (col < row) {
td.style.background = 'grey';
td.style.color = 'grey';
}
}")
If I can get help write a logic that - for each cell, if's respective To's value is greater than column name, black it out(eg every cell of column 24 is compared with 12, 24, 36 etc and 36 on it is blacked) it's help unblock me. Appreciate any help on this.