nutterb / pixiedust

Tables So Beautifully Fine-Tuned You Will Believe It's Magic.
178 stars 18 forks source link

dust() does not allow 1 column tables #123

Open charlieflipside opened 1 year ago

charlieflipside commented 1 year ago
# works
dust(mtcars) %>% sprinkle_print_method("console")

mpg cyl disp hp drat wt qsec vs am gear carb 1 21 6 160 110 3.9 2.62 16.46 0 1 4 4 2 21 6 160 110 3.9 2.875 17.02 0 1 4 4

# error
dust(mtcars[, "mpg"]) %>% sprinkle_print_method("console")

Error in .rbind_internal(if (nrow(head) > 1) subhead else NULL, body[Divisions$row_num[Divisions$div_num == : All objects in ... must be data frames

Similarly:

  # error
  dust(
    data.frame(
        col1 = "hi"
    )
) %>% sprinkle_print_method("console")

Error in .rbind_internal(if (nrow(head) > 1) head[-1, ] else NULL, body[Divisions$row_num[Divisions$div_num == : All objects in ... must be data frames

  # works
  dust(
    data.frame(
        col1 = "hi",
        col2 = "hello"
    )
) %>% sprinkle_print_method("console")

col1 col2 1 hi hello