mlr-org/ParamHelpers

designs: refactor column type enforcing

Opened this issue · 0 comments

sometimes in data frames we have to enforce the column type so it matches perfectly the type in the parset.

a) janek uses fixDesignVarTypes in generateDesignOfDefaults

b) but in dfRowsToList we have this

  if (enforce.col.types) {
    types = getParamTypes(par.set, df.cols = TRUE)
    for (i in seq_along(types)) {
      tt = types[i]
      if (tt == "factor")
        df[,i] = as.factor(df[, i])
      else
        df[,i] = as(df[,i], tt)
    }
  }

does the same and should be nified / refactored