Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ``` r
- rm(list=ls())
- library(tidyverse)
- library(duckplyr)
- #> The duckplyr package is configured to fall back to dplyr when it encounters an
- #> incompatibility. Fallback events can be collected and uploaded for analysis to
- #> guide future development. By default, data will be collected but no data will
- #> be uploaded.
- #> ℹ Automatic fallback uploading is not controlled and therefore disabled, see
- #> `?duckplyr::fallback()`.
- #> ✔ Number of reports ready for upload: 11.
- #> → Review with `duckplyr::fallback_review()`, upload with
- #> `duckplyr::fallback_upload()`.
- #> ℹ Configure automatic uploading with `duckplyr::fallback_config()`.
- #> ✔ Overwriting dplyr methods with duckplyr methods.
- #> ℹ Turn off with `duckplyr::methods_restore()`.
- library(tictoc)
- library(arrow)
- #>
- #> Attaching package: 'arrow'
- #> The following object is masked from 'package:lubridate':
- #>
- #> duration
- #> The following object is masked from 'package:utils':
- #>
- #> timestamp
- # Increased the size of data
- ## dd <- tibble(x=1:100000000, y=rep(LETTERS[1:20], 5000000))
- ## write_csv(dd, "test.csv")
- df <- duck_csv("test.csv")
- system.time({
- df_stat <- df |>
- summarise(total=sum(x), .by = y) |>
- collect() |>
- as_tibble()
- })
- #> user system elapsed
- #> 28.368 0.437 7.866
- df2 <- open_dataset("test.csv",
- format = "csv",
- skip_rows = 0)
- system.time({
- df_stat2 <- df2 |>
- group_by(y) |>
- summarise(total=sum(x)) |>
- ungroup() |>
- collect()
- })
- #> user system elapsed
- #> 12.319 0.352 7.477
- print("So far so good")
- #> [1] "So far so good"
- ```
- <sup>Created on 2024-12-31 with [reprex v2.1.0](https://reprex.tidyverse.org)</sup>
Advertisement
Add Comment
Please, Sign In to add comment