Is there a way to edit task$data()
or replace it with a new data.frame()
with exactly the same colnames?
I've tried the following task_train$data() <- newDF
and task_train$data <- newDF
. They both result in Error in task_train$data() <- di : invalid (NULL) left side of assignment
and Error in task_train$data <- newDF: cannot change value of locked binding for 'data'
, respectively.
Once you create the task all further data transformations, augmentations etc. should be performed using pipelines. This is especially handy when performing resampling/tuning since it avoids data leakage.
Based on the comment by @pat-s this is not only my opinion but the opinion of the core mlr team. And this is the reason why direct editing of the task data (in ways you show in the question) fails.