Make a custom objective function that depends on other columns of the input data in R

I am having issue implementing recency-weighting for xgboost training in R (i.e. passing a weight vector to xgb.DMatrix) - although the weighting affects the learning curve readout for the training set, it does not appear to have any impact at all on the actual model produced - performance in the test set is identical. This is very weird but
I can’t seem to get to the bottom of this issue or generate a reproducible example. So instead I would like to pass the Date column of the features to a custom loss function, something like:

custom_loss <- function(preds,dat) {
  labels <- getinfo(dat,"label")
  dates <- [a vector corresponding to the dates associated with each prediction]
  grad = f(dates)*-2*(labels - preds)
  hess = f(dates)*2
  [where f is an increasing function of the value in dates, so later samples matter more when training]
  return(list(grad=grad,hess=hess))
}

So somehow I would need to pass the vector of dates associated with whatever labels are being evaluated by the custom objective function, but I can’t seem to figure out how to do this. Any suggestions?

Hmm, assigning data weights would usually affect the model produced. Unfortunately, it is currently not possible to access individual columns of a data matrix inside the custom metric function.

We should find out why changing data weights seem to have no effect. Can you post an example?

I have tried to create a reproducible example but bizarrely on dummy data it does seem to work. Let me have a play around and see if I can replicate it. NB I have only weighted the dtrain matrix, not the dtest matrix.