You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(errorlocate)
## Loading required package: validaterules<- validator(if (sector%in% c(1,2)) turnover>0)
# faulty recorddata<-data.frame(sector=1, turnover=0)
weight<- c(sector=2, turnover=1)
# no errors found, but a warning is given
locate_errors(data, rules, weight=weight)$errors## Warning: 'sector' seems a categorical variable, please recode it as a factor in the data.## Only use character or logical values in %in% statements to prevent this warning.## sector turnover## [1,] FALSE FALSE
Recoding sector as factor fixes the issue:
data$sector<-factor(data$sector)
locate_errors(data, rules, weight=weight)$errors## Warning: 'sector' seems a categorical variable, please recode it as a factor in the data.## Only use character or logical values in %in% statements to prevent this warning.## sector turnover## [1,] FALSE TRUE
When a categorical variable is coded as an integer, the resulting mip solver, does not know that it is categorical.
This works though:
Thanks to Jeffrey Hoogland for reporting
The text was updated successfully, but these errors were encountered: