duckdblabs/duckplyr

pretty print() method would be nice

Opened this issue · 6 comments

There is no explicit print method for class duckplyr_df. Something prettier than the base R method would be nice. I use this:

print.duckplyr_df <- function(x,...){print(class(x));print(as_tibble(x),...)}

Thanks, Art. A tibble converted to a duckframe will still print as a tibble:

data.frame(a = 1) |>
  duckplyr::as_duckplyr_df()
#>   a
#> 1 1
tibble::tibble(a = 1) |>
  duckplyr::as_duckplyr_df()
#> # A tibble: 1 × 1
#>       a
#>   <dbl>
#> 1     1

Created on 2024-06-08 with reprex v2.1.0

Does this help?

To me, it feels like creating a tibble should be the default.

Should we do

as_duckplyr_df <- function(..., class = class(tibble()))

with an option to override?

Yeah, I think so.

Done in bc7c8de for df_from_file() . Not yet sure about as_duckplyr_df(), it's used in 888 places now, and likely to break.

Maybe as_duckplyr_tibble() and as_duckplyr_tbl() ?

I think as_duckplyr_tibble() should be adequate.