diff --git a/README.Rmd b/README.Rmd index 914fb9f9..4db6da8d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -53,6 +53,12 @@ pak::pak("duckdblabs/duckplyr") ## Examples +```{r attach} +library(conflicted) +library(duckplyr) +conflict_prefer("filter", "duckplyr") +``` + There are two ways to use duckplyr. 1. To enable duckplyr for individual data frames, use `as_duckplyr_df()` as the first step in your pipe. @@ -65,12 +71,6 @@ See also the companion [demo repository](https://github.com/Tmonster/duckplyr_de This example illustrates usage of duckplyr for individual data frames. -```{r individual} -library(conflicted) -library(duckplyr) -conflict_prefer("filter", "duckplyr") -``` - Use `as_duckplyr_df()` to enable processing with duckdb: ```{r} @@ -117,12 +117,6 @@ out This example illustrates usage of duckplyr for all data frames in the R session. -```{r session} -library(conflicted) -library(duckplyr) -conflict_prefer("filter", "duckplyr") -``` - Use `methods_overwrite()` to enable processing with duckdb for all data frames: ```{r} diff --git a/README.md b/README.md index 31e62a8c..b965034f 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,17 @@ Or from [GitHub](https://github.com/) with: ## Examples +
+library(conflicted)
+library(duckplyr)
+conflict_prefer("filter", "duckplyr")
+#> [conflicted] Will prefer duckplyr::filter over
+#> any other package.
+ There are two ways to use duckplyr. -1. To enable duckplyr for individual data frames, use `as_duckplyr_df()` as the first step in your pipe. -2. To enable duckplyr for the entire session, use `methods_overwrite()`. +1. To enable duckplyr for individual data frames, use [`as_duckplyr_df()`](https://duckdblabs.github.io/duckplyr/reference/as_duckplyr_df.html) as the first step in your pipe. +2. To enable duckplyr for the entire session, use [`methods_overwrite()`](https://duckdblabs.github.io/duckplyr/reference/methods_overwrite.html). The examples below illustrate both methods. See also the companion [demo repository](https://github.com/Tmonster/duckplyr_demo) for a use case with a large dataset. @@ -43,13 +50,6 @@ The examples below illustrate both methods. See also the companion [demo reposit This example illustrates usage of duckplyr for individual data frames. -
-library(conflicted)
-library(duckplyr)
-conflict_prefer("filter", "duckplyr")
-#> [conflicted] Will prefer duckplyr::filter over
-#> any other package.
- Use [`as_duckplyr_df()`](https://duckdblabs.github.io/duckplyr/reference/as_duckplyr_df.html) to enable processing with duckdb:
@@ -127,7 +127,7 @@ All data frame operations are supported. Computation happens upon the first requ
 #> Filter [!=(species, 'Gentoo')]
 #>   Aggregate [species, sex, mean(bill_area)]
 #>     Projection [species as species, island as island, bill_length_mm as bill_length_mm, bill_depth_mm as bill_depth_mm, flipper_length_mm as flipper_length_mm, body_mass_g as body_mass_g, sex as sex, "year" as year, *(bill_length_mm, bill_depth_mm) as bill_area]
-#>       r_dataframe_scan(0x13c2aa118)
+#>       r_dataframe_scan(0x10c4c7628)
 #> 
 #> ---------------------
 #> -- Result Columns  --
@@ -136,7 +136,7 @@ All data frame operations are supported. Computation happens upon the first requ
 #> - sex (VARCHAR)
 #> - mean_bill_area (DOUBLE)
 #> 
-#> [1] 656.8523 694.9360 984.2279 819.7503 770.2627
+#> [1] 770.2627 656.8523 819.7503 694.9360 984.2279 After the computation has been carried out, the results are available immediately: @@ -145,23 +145,16 @@ After the computation has been carried out, the results are available immediatel #> # A tibble: 5 × 3 #> species sex mean_bill_area #> <chr> <chr> <dbl> -#> 1 Adelie female 657. -#> 2 Adelie NA 695. -#> 3 Chinstrap male 984. -#> 4 Chinstrap female 820. -#> 5 Adelie male 770. +#> 1 Adelie male 770. +#> 2 Adelie female 657. +#> 3 Chinstrap female 820. +#> 4 Adelie NA 695. +#> 5 Chinstrap male 984. ### Session-wide usage This example illustrates usage of duckplyr for all data frames in the R session. -
-library(conflicted)
-library(duckplyr)
-conflict_prefer("filter", "duckplyr")
-#> [conflicted] Removing existing preference.
-#> [conflicted] Will prefer duckplyr::filter over any other package.
- Use [`methods_overwrite()`](https://duckdblabs.github.io/duckplyr/reference/methods_overwrite.html) to enable processing with duckdb for all data frames:
@@ -198,7 +191,7 @@ Querying the number of rows also starts the computation:
 #> Filter [!=(species, 'Gentoo')]
 #>   Aggregate [species, sex, mean(bill_area)]
 #>     Projection [species as species, island as island, bill_length_mm as bill_length_mm, bill_depth_mm as bill_depth_mm, flipper_length_mm as flipper_length_mm, body_mass_g as body_mass_g, sex as sex, "year" as year, *(bill_length_mm, bill_depth_mm) as bill_area]
-#>       r_dataframe_scan(0x13b4e4028)
+#>       r_dataframe_scan(0x10a81d568)
 #> 
 #> ---------------------
 #> -- Result Columns  --