leeper / prediction

Tidy, Type-Safe 'prediction()' Methods

Home Page:https://cran.r-project.org/package=prediction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build_datalist() with specified at breaks factor's levels

tzoltak opened this issue · comments

  • [x ] a suggested code or documentation change, improvement to the code, or feature request

If user specifies some value using at that regards to a factor variable, this variable in data that is returned by build_datalist() is always a factor with only one level - this specified with at irrespective original set of levels of this factor. It will be more reasonable to keep original levels.

dat <- mtcars
dat$cyl <- as.factor(dat$cyl)
levels(dat$cyl)
newDat <- build_datalist(dat, list(cyl = '6'))
levels(newDat[[1]]$cyl)

This issue is related to #124 at @leeper /margins.