Convert to a duckplyr data frame
Source:R/as_duckplyr_df.R
, R/as_duckplyr_tibble.R
as_duckplyr_df.Rd
These functions convert a data-frame-like input to an object of class "duckpylr_df"
.
For such objects,
dplyr verbs such as mutate()
, select()
or filter()
will attempt to use DuckDB.
If this is not possible, the original dplyr implementation is used.
as_duckplyr_df()
requires the input to be a plain data frame or a tibble,
and will fail for any other classes, including subclasses of "data.frame"
or "tbl_df"
.
This behavior is likely to change, do not rely on it.
as_duckplyr_tibble()
converts the input to a tibble and then to a duckplyr data frame.
Value
For as_duckplyr_df()
, an object of class "duckplyr_df"
,
inheriting from the classes of the .data
argument.
For as_duckplyr_df()
, an object of class
c("duckplyr_df", class(tibble()))
.
Details
Set the DUCKPLYR_FALLBACK_INFO
and DUCKPLYR_FORCE
environment variables
for more control over the behavior, see config for more details.
Examples
tibble(a = 1:3) %>%
mutate(b = a + 1)
#> # A tibble: 3 × 2
#> a b
#> <int> <dbl>
#> 1 1 2
#> 2 2 3
#> 3 3 4
tibble(a = 1:3) %>%
as_duckplyr_df() %>%
mutate(b = a + 1)
#> materializing:
#> ---------------------
#> --- Relation Tree ---
#> ---------------------
#> Projection [a as a, "+"(a, 1.0) as b]
#> r_dataframe_scan(0x564a92d27ea8)
#>
#> ---------------------
#> -- Result Columns --
#> ---------------------
#> - a (INTEGER)
#> - b (DOUBLE)
#>
#> # A tibble: 3 × 2
#> a b
#> <int> <dbl>
#> 1 1 2
#> 2 2 3
#> 3 3 4