romainkp / stremr

Streamlined Estimation for Static, Dynamic and Stochastic Treatment Regimes in Longitudinal Data
MIT License
38 stars 8 forks source link

factor with 1 level only #17

Closed romainkp closed 7 years ago

romainkp commented 8 years ago

When a factor variable can take on only one value, importData creates a dummy of class "list" which cannot be handled by subsequent stremr routines (Error message is produced).

Stremr should catch the problem, print a warning and create a single dummy variable of class "integer".

osofr commented 7 years ago

Should be working correctly now. Added a check for number of levels and if a factor has only two or fewer levels, it is simply converted to an integer.