timelyportfolio/d3r

handle NA

timelyportfolio opened this issue · 1 comments

I made a bad assumption, so NA are not treated properly. As a simple case,

d3r::d3_nest(
  data.frame(
    level1 = rep("a",3),
    level2 = c(NA,"a.1","a.2"),
    value = 1:3
  ),
  value_cols = "value"
)

image

In my mind proper behavior would be NA should not be nested as children. In the above example, value: 1 should not be in children, so should be promoted a level.

With example above, we now get two children and the value is promoted to the higher level.

image