leeper / prediction

Tidy, Type-Safe 'prediction()' Methods
https://cran.r-project.org/package=prediction
Other
89 stars 14 forks source link

build_datalist() with specified at breaks factor's levels #39

Closed tzoltak closed 4 years ago

tzoltak commented 4 years ago

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)
tzoltak commented 4 years ago

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