Closed kylebaron closed 2 years ago
Hey @kylebaron - This looks great! One thought - Can you make sure it always preserves the order factors are defined in the yspec and only adds the "Missing" to the end? It looks like you're already taking care of this but one thing I ran in to when I did this manually was that it rearranged the order of my factors.
@KatherineKayMRG One thing that I'm doing is refusing to process any column that is already a factor; when that column gets processed, it just returns a factor if it finds one coming in. Otherwise, we're working on non-factors and the order of the levels comes from the spec. Because of that, we just put "missing" as the last level when building the factor. That is, we get a chance to intervene before the factor order is set to make sure "missing" is last.
That's great and much nicer than how I had to do it manually. Thanks for explaining
Summary
When calling
ys_add_factors()
, look for missing values and fill in if requested.missing
, which must beNULL
orcharacter(0)
Reprex
Created on 2021-08-13 by the reprex package (v2.0.0)