diff --git a/pkgdown.yml b/pkgdown.yml index 48ca5b19..2a33d001 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -5,7 +5,7 @@ articles: faq: faq.html r-and-polars-expressions: r-and-polars-expressions.html tidypolars: tidypolars.html -last_built: 2024-12-21T08:46Z +last_built: 2024-12-21T08:56Z urls: reference: https://tidypolars.etiennebacher.com/reference article: https://tidypolars.etiennebacher.com/articles diff --git a/reference/group_by.RPolarsDataFrame.html b/reference/group_by.RPolarsDataFrame.html index c65567b8..61878761 100644 --- a/reference/group_by.RPolarsDataFrame.html +++ b/reference/group_by.RPolarsDataFrame.html @@ -130,9 +130,9 @@

Examples#> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪════════════╪════════════╡ -#> │ 4.0 ┆ 105.136364 ┆ 82.636364 │ -#> │ 6.0 ┆ 183.314286 ┆ 122.285714 │ #> │ 8.0 ┆ 353.1 ┆ 209.214286 │ +#> │ 6.0 ┆ 183.314286 ┆ 122.285714 │ +#> │ 4.0 ┆ 105.136364 ┆ 82.636364 │ #> └─────┴────────────┴────────────┘ by_cyl |> filter(disp == max(disp)) #> shape: (3, 11) diff --git a/reference/summarize.RPolarsDataFrame.html b/reference/summarize.RPolarsDataFrame.html index b497f739..4c08aea7 100644 --- a/reference/summarize.RPolarsDataFrame.html +++ b/reference/summarize.RPolarsDataFrame.html @@ -112,9 +112,9 @@

Examples#> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪══════════╪══════════╡ -#> │ 8.0 ┆ 3.285714 ┆ 0.726273 │ -#> │ 4.0 ┆ 4.090909 ┆ 0.53936 │ #> │ 6.0 ┆ 3.857143 ┆ 0.690066 │ +#> │ 4.0 ┆ 4.090909 ┆ 0.53936 │ +#> │ 8.0 ┆ 3.285714 ┆ 0.726273 │ #> └─────┴──────────┴──────────┘ # an alternative syntax is to use `.by` @@ -128,8 +128,8 @@

Examples#> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪══════════╪══════════╡ #> │ 8.0 ┆ 3.285714 ┆ 0.726273 │ -#> │ 6.0 ┆ 3.857143 ┆ 0.690066 │ #> │ 4.0 ┆ 4.090909 ┆ 0.53936 │ +#> │ 6.0 ┆ 3.857143 ┆ 0.690066 │ #> └─────┴──────────┴──────────┘ diff --git a/reference/tidypolars-options.html b/reference/tidypolars-options.html index e943f247..f19f6bee 100644 --- a/reference/tidypolars-options.html +++ b/reference/tidypolars-options.html @@ -78,11 +78,11 @@

Examples#> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞═════╪═════╡ -#> │ 2.0 ┆ 2.0 │ -#> │ 1.0 ┆ 3.0 │ -#> │ 5.0 ┆ 5.0 │ -#> │ 3.0 ┆ 1.0 │ -#> │ 1.0 ┆ 1.0 │ +#> │ 2.0 ┆ 1.0 │ +#> │ 1.0 ┆ 5.0 │ +#> │ 5.0 ┆ 1.0 │ +#> │ 3.0 ┆ 3.0 │ +#> │ 1.0 ┆ 2.0 │ #> └─────┴─────┘ # But one can make this stricter and throw an error when this happens diff --git a/search.json b/search.json index a146f253..52c362f8 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to tidypolars","title":"Contributing to tidypolars","text":"outlines propose change tidypolars.","code":""},{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to tidypolars","text":"Small typos grammatical errors vignettes can fixed directly Github interface since vignettes automatically rendered pkgdown. Fixing typos documentation functions (“Reference” page) requires editing source corresponding .R file run devtools::document(). edit .Rd file man/.","code":""},{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":"filing-an-issue","dir":"","previous_headings":"","what":"Filing an issue","title":"Contributing to tidypolars","text":"easiest way propose change new feature file issue. ’ve found bug, may also create associated issue. possible, try illustrate proposal bug minimal reproducible example.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":"general-information","dir":"","previous_headings":"Pull requests","what":"General information","title":"Contributing to tidypolars","text":"Please create Git branch pull request (PR). tidypolars uses roxygen2, Markdown syntax, documentation. PR user-visible change, may add bullet point NEWS.md describing changes made. may optionally add GitHub username, links relevant issue(s)/PR(s).","code":""},{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":"how-to-add-support-for-an-r-function-in-tidypolars","dir":"","previous_headings":"Pull requests","what":"How to add support for an R function in tidypolars?","title":"Contributing to tidypolars","text":"use function supported, tidypolars throw error. doesn’t mean tidypolars support , simply implemented yet. tidypolars can technically support hundreds functions manipulate numbers, strings, dates, limited tidyverse. first step come across unsupported function find corresponding syntax polars. Just example, suppose stringr::str_ends() yet supported (actually ). first define simple test data.frame DataFrame counterpart polars: , find polars syntax gives output stringr::str_ends(). case, polars string methods $ends_with(): interests us expression inside $with_columns() call. Now know polars translation, let’s put function tidypolars know. Internally, tidypolars prefix function name (str_ends) pl_ look translated functions. Depending function translate, can stored different places. function works strings, can store R/funs-string.R. add support negate argument, look like: can notice new function must named pl__. multiple packages can export functions name (example data.table::() dplyr::()). Therefore, want ensure translation called function comes specific package. check_empty_dots(...) grab additional arguments stringr::str_ends() might ignore counterparts polars (also adds message warning user arguments used). package reloaded, can use function tidypolars workflow: Finally, thing left add tests tests/testthat folder.","code":"library(dplyr, warn.conflicts = FALSE) library(stringr) library(polars) test <- tibble(x = c(\"abc\", \"a1\", \"dac\")) test_pl <- pl$DataFrame(x = c(\"abc\", \"a1\", \"dac\")) test |> mutate(ends_with_c = str_ends(x, \"c\")) ## # A tibble: 3 × 2 ## x ends_with_c ## ## 1 abc TRUE ## 2 a1 FALSE ## 3 dac TRUE test_pl$with_columns( ends_with_c = pl$col(\"x\")$str$ends_with(\"c\") ) ## shape: (3, 2) ## ┌─────┬─────────────┐ ## │ x ┆ ends_with_c │ ## │ --- ┆ --- │ ## │ str ┆ bool │ ## ╞═════╪═════════════╡ ## │ abc ┆ true │ ## │ a1 ┆ false │ ## │ dac ┆ true │ ## └─────┴─────────────┘ pl_str_ends_stringr <- function(string, pattern, negate = FALSE, ...) { check_empty_dots(...) out <- string$str$ends_with(pattern) if (isTRUE(negate)) { out$not() } else { out } } library(tidypolars, warn.conflicts = FALSE) test_pl |> mutate(ends_with_c = str_ends(x, \"c\")) ## shape: (3, 2) ## ┌─────┬─────────────┐ ## │ x ┆ ends_with_c │ ## │ --- ┆ --- │ ## │ str ┆ bool │ ## ╞═════╪═════════════╡ ## │ abc ┆ true │ ## │ a1 ┆ false │ ## │ dac ┆ true │ ## └─────┴─────────────┘"},{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":"testing-changes","dir":"","previous_headings":"Pull requests","what":"Testing changes","title":"Contributing to tidypolars","text":"tidypolars uses testthat check functions expected output. changes affect behavior functions (example adding extra argument), add tests related file tests/testthat. tidyverse functions apply entire dataframe (e.g., drop_na()) test file (test-drop_na.R case). Functions apply one multiple vectors (.e. functions used mutate(), summarize(), etc.) tested specific files. added function R/funs-string.R, add tests tests/testthat/test-funs_string.R (datetime functions, etc.). matter type function added modified, write tests Polars DataFrames. automatically modified running tests run LazyFrames well (instance, file test-drop_na-lazy.R automatically generated).","code":""},{"path":"https://tidypolars.etiennebacher.com/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 tidypolars authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/faq.html","id":"is-tidypolars-slower-than-polars","dir":"Articles","previous_headings":"","what":"Is tidypolars slower than polars?","title":"FAQ","text":", just marginally. objective tidypolars modify data, simply translate tidyverse syntax polars syntax. polars still charge data manipulations hood. Therefore, might minor overhead still need parse expressions rewrite polars syntax (see Parsing expressions vignette) marginal.","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/faq.html","id":"am-i-stuck-with-tidypolars","dir":"Articles","previous_headings":"","what":"Am I stuck with tidypolars?","title":"FAQ","text":", tidypolars always return DataFrames, LazyFrames Series. Therefore, point want use polars need control want reduce number dependencies, can easily .","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/faq.html","id":"do-i-still-need-to-load-polars","dir":"Articles","previous_headings":"","what":"Do I still need to load polars?","title":"FAQ","text":"Yes, tidypolars doesn’t provide functions create polars DataFrame LazyFrame read data. ’ll still need use polars .","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/faq.html","id":"can-i-see-some-benchmarks-with-other-tools","dir":"Articles","previous_headings":"","what":"Can I see some benchmarks with other tools?","title":"FAQ","text":"Making accurate benchmarks data wrangling tools difficult won’t try (just put one homepage give idea performance, means comprehensive). refer DuckDB benchmarks.","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"how-does-tidypolars-translate-r-expressions-into-polars-expressions","dir":"Articles","previous_headings":"","what":"How does tidypolars translate R expressions into Polars expressions?","title":"R and Polars expressions","text":"tidypolars receives expression, runs function translate() several times components translated Polars equivalent. four possible components: single values, column names, external objects, functions.","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"single-values-column-names-and-external-objects","dir":"Articles","previous_headings":"How does tidypolars translate R expressions into Polars expressions?","what":"Single values, column names, and external objects","title":"R and Polars expressions","text":"pass single value, like x = 1 x = \"\", wrapped pl$lit(). also case external objects difference need wrapped {{ }} evaluated wrapped pl$lit(). Column names, like x = mpg, wrapped pl$col().","code":"x = \"a\" -> x = pl$lit(\"a\") x = {{ some_value }} -> x = pl$lit(*value*) x = mpg -> x = pl$col(\"mpg\")"},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"functions","dir":"Articles","previous_headings":"How does tidypolars translate R expressions into Polars expressions?","what":"Functions","title":"R and Polars expressions","text":"Functions split two categories: built-functions (.e functions provided base R packages), user-defined functions (UDF) written user ().","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"built-in-functions","dir":"Articles","previous_headings":"How does tidypolars translate R expressions into Polars expressions? > Functions","what":"Built-in functions","title":"R and Polars expressions","text":"first case, tidypolars checks function name whether already translated internally. example, call R function mean(x, trim = 2), looks translation mean(). can see list supported R functions bottom vignette. Note essential base R functions supported, well many functions dplyr stringr example. Now tidypolars knows translation mean() exists, parses arguments call translate Polars syntax: internally, x converted pl$col(\"x\") column \"x\" data. Sometimes, additional arguments equivalent Polars. case argument trim . case, tidypolars ignores argument warns user: behavior can changed throw error instead.","code":"library(tidypolars) library(polars) mtcars |> as_polars_df() |> mutate(x = mean(mpg, trim = 2)) #> Warning: #> Package tidypolars doesn't know how to use some arguments of `mean()`. #> The following argument(s) will be ignored: `trim`. #> shape: (32, 12) #> ┌──────┬─────┬───────┬───────┬───┬─────┬──────┬──────┬───────────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ am ┆ gear ┆ carb ┆ x │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪══════╪══════╪═══════════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 20.090625 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 20.090625 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 1.0 ┆ 20.090625 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 1.0 ┆ 20.090625 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 2.0 ┆ 20.090625 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 2.0 ┆ 20.090625 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 4.0 ┆ 20.090625 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 6.0 ┆ 20.090625 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 8.0 ┆ 20.090625 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 2.0 ┆ 20.090625 │ #> └──────┴─────┴───────┴───────┴───┴─────┴──────┴──────┴───────────┘"},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"user-defined-functions","dir":"Articles","previous_headings":"How does tidypolars translate R expressions into Polars expressions? > Functions","what":"User-defined functions","title":"R and Polars expressions","text":"User-defined functions (UDF) challenging. Indeed, technically possible inspect code inside UDF, rewriting match Polars syntax extremely complicated. situation, rewrite custom function using Polars syntax returns Polars expression. example, make function standardize column like : Remember column name used x end wrapped pl$col(), check function returns Polars expression, provide pl$col() call: function correctly returns Polars expression, can now use like function:","code":"pl_standardize <- function(x) { (x - x$mean()) / x$std() } pl_standardize(pl$col(\"mpg\")) #> polars Expr: [([(col(\"mpg\")) - (col(\"mpg\").mean())]) // (col(\"mpg\").std())] mtcars |> as_polars_df() |> mutate(x = pl_standardize(mpg)) #> shape: (32, 12) #> ┌──────┬─────┬───────┬───────┬───┬─────┬──────┬──────┬───────────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ am ┆ gear ┆ carb ┆ x │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪══════╪══════╪═══════════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 0.150885 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 0.150885 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 1.0 ┆ 0.449543 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 1.0 ┆ 0.217253 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 2.0 ┆ -0.230735 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 2.0 ┆ 1.710547 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 4.0 ┆ -0.711907 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 6.0 ┆ -0.064813 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 8.0 ┆ -0.844644 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 2.0 ┆ 0.217253 │ #> └──────┴─────┴───────┴───────┴───┴─────┴──────┴──────┴───────────┘"},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"special-case-across","dir":"Articles","previous_headings":"How does tidypolars translate R expressions into Polars expressions? > Functions","what":"Special case: across()","title":"R and Polars expressions","text":"across() useful function applies function (list functions) selection columns. accepts built-functions, UDFs, anonymous functions. Similarly, UDFs anonymous functions error don’t return Polars expression:","code":"mtcars |> as_polars_df() |> mutate( across( .cols = contains(\"a\"), list(mean = mean, stand = pl_standardize, ~ sd(.x)) ) ) #> shape: (32, 23) #> ┌──────┬─────┬───────┬───────┬───┬──────────┬───────────┬────────────┬────────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ gear_3 ┆ carb_mean ┆ carb_stand ┆ carb_3 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪══════════╪═══════════╪════════════╪════════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ 0.735203 ┆ 1.6152 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ 0.735203 ┆ 1.6152 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ -1.122152 ┆ 1.6152 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ -1.122152 ┆ 1.6152 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ -0.503034 ┆ 1.6152 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ -0.503034 ┆ 1.6152 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ 0.735203 ┆ 1.6152 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ 1.97344 ┆ 1.6152 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ 3.211677 ┆ 1.6152 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ -0.503034 ┆ 1.6152 │ #> └──────┴─────┴───────┴───────┴───┴──────────┴───────────┴────────────┴────────┘ mtcars |> as_polars_df() |> mutate( across( .cols = contains(\"a\"), .fns = list( mean = mean, function(x) { (x - mean(x)) / sd(x) }, ~ sd(.x) ) ) ) #> Error in `mutate()`: #> ! Could not evaluate an anonymous function in `across()`. #> ℹ Are you sure the anonymous function returns a Polars expression?"},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Etienne Bacher. Author, maintainer, copyright holder.","code":""},{"path":"https://tidypolars.etiennebacher.com/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Bacher E (2024). tidypolars: Get Power Polars Syntax Tidyverse. R package version 0.12.0.9000, https://etiennebacher.r-universe.dev/tidypolars, https://tidypolars.etiennebacher.com.","code":"@Manual{, title = {tidypolars: Get the Power of Polars with the Syntax of the Tidyverse}, author = {Etienne Bacher}, year = {2024}, note = {R package version 0.12.0.9000, https://etiennebacher.r-universe.dev/tidypolars}, url = {https://tidypolars.etiennebacher.com}, }"},{"path":"https://tidypolars.etiennebacher.com/index.html","id":"tidypolars-","dir":"","previous_headings":"","what":"Get the Power of Polars with the Syntax of the Tidyverse","title":"Get the Power of Polars with the Syntax of the Tidyverse","text":"ℹ️ R package “tidypolars”. Python one : markfairbanks/tidypolars","code":""},{"path":"https://tidypolars.etiennebacher.com/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"Get the Power of Polars with the Syntax of the Tidyverse","text":"tidypolars provides polars backend tidyverse. aim tidypolars enable users keep existing tidyverse code using polars background benefit large performance gains. thing needs change way data imported R session. See “Getting started” vignette gentle introduction tidypolars. Since work rewriting tidyverse code polars syntax, tidypolars polars similar performance. main purpose benchmark show polars tidypolars close give idea performance. thorough, representative benchmarks polars, take look DuckDB benchmarks instead.","code":"library(collapse, warn.conflicts = FALSE) #> collapse 2.0.16, see ?`collapse-package` or ?`collapse-documentation` library(dplyr, warn.conflicts = FALSE) library(dtplyr) library(polars) library(tidypolars) large_iris <- data.table::rbindlist(rep(list(iris), 100000)) large_iris_pl <- as_polars_lf(large_iris) large_iris_dt <- lazy_dt(large_iris) format(nrow(large_iris), big.mark = \",\") #> [1] \"15,000,000\" bench::mark( polars = { large_iris_pl$ select(c(\"Sepal.Length\", \"Sepal.Width\", \"Petal.Length\", \"Petal.Width\"))$ with_columns( pl$when( (pl$col(\"Petal.Length\") / pl$col(\"Petal.Width\") > 3) )$then(pl$lit(\"long\"))$ otherwise(pl$lit(\"large\"))$ alias(\"petal_type\") )$ filter(pl$col(\"Sepal.Length\")$is_between(4.5, 5.5))$ collect() }, tidypolars = { large_iris_pl |> select(starts_with(c(\"Sep\", \"Pet\"))) |> mutate( petal_type = ifelse((Petal.Length / Petal.Width) > 3, \"long\", \"large\") ) |> filter(between(Sepal.Length, 4.5, 5.5)) |> compute() }, dplyr = { large_iris |> select(starts_with(c(\"Sep\", \"Pet\"))) |> mutate( petal_type = ifelse((Petal.Length / Petal.Width) > 3, \"long\", \"large\") ) |> filter(between(Sepal.Length, 4.5, 5.5)) }, dtplyr = { large_iris_dt |> select(starts_with(c(\"Sep\", \"Pet\"))) |> mutate( petal_type = ifelse((Petal.Length / Petal.Width) > 3, \"long\", \"large\") ) |> filter(between(Sepal.Length, 4.5, 5.5)) |> as.data.frame() }, collapse = { large_iris |> fselect(c(\"Sepal.Length\", \"Sepal.Width\", \"Petal.Length\", \"Petal.Width\")) |> fmutate( petal_type = data.table::fifelse((Petal.Length / Petal.Width) > 3, \"long\", \"large\") ) |> fsubset(Sepal.Length >= 4.5 & Sepal.Length <= 5.5) }, check = FALSE, iterations = 40 ) #> Warning: Some expressions had a GC in every iteration; #> so filtering is disabled. #> # A tibble: 5 × 6 #> expression min median `itr/sec` mem_alloc #> #> 1 polars 277.93ms 304.59ms 3.17 1.99MB #> 2 tidypolars 286.78ms 362.65ms 2.35 1.2MB #> 3 dplyr 3.16s 3.63s 0.257 1.79GB #> 4 dtplyr 1.58s 1.92s 0.461 1.72GB #> 5 collapse 702.79ms 948.19ms 0.987 745.96MB #> # ℹ 1 more variable: `gc/sec` # NOTE: do NOT take the \"mem_alloc\" results into account. # `bench::mark()` doesn't report the accurate memory usage for packages calling # Rust code."},{"path":"https://tidypolars.etiennebacher.com/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Get the Power of Polars with the Syntax of the Tidyverse","text":"tidypolars built polars, available CRAN. means tidypolars also can’t CRAN. However, can install R-universe.","code":"Sys.setenv(NOT_CRAN = \"true\") install.packages(\"tidypolars\", repos = c(\"https://community.r-multiverse.org\", 'https://cloud.r-project.org'))"},{"path":"https://tidypolars.etiennebacher.com/index.html","id":"contributing","dir":"","previous_headings":"","what":"Contributing","title":"Get the Power of Polars with the Syntax of the Tidyverse","text":"find bugs errors documentation? want tidypolars support functions? Take look contributing guide instructions bug report pull requests.","code":""},{"path":"https://tidypolars.etiennebacher.com/index.html","id":"acknowledgements","dir":"","previous_headings":"","what":"Acknowledgements","title":"Get the Power of Polars with the Syntax of the Tidyverse","text":"website theme heavily inspired Matthew Kay’s ggblend package: https://mjskay.github.io/ggblend/. package hex logo created Hubert Hałun part Appsilon Hex Contest.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/arrange.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Order rows using column values — arrange.RPolarsDataFrame","title":"Order rows using column values — arrange.RPolarsDataFrame","text":"Order rows using column values","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/arrange.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Order rows using column values — arrange.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' arrange(.data, ..., .by_group = FALSE)"},{"path":"https://tidypolars.etiennebacher.com/reference/arrange.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Order rows using column values — arrange.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Variables, functions variables. Use desc() sort variable descending order. .by_group TRUE, sort data within groups.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/arrange.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Order rows using column values — arrange.RPolarsDataFrame","text":"","code":"pl_test <- polars::pl$DataFrame( x1 = c(\"a\", \"a\", \"b\", \"a\", \"c\"), x2 = c(2, 1, 5, 3, 1), value = sample(1:5) ) arrange(pl_test, x1) #> shape: (5, 3) #> ┌─────┬─────┬───────┐ #> │ x1 ┆ x2 ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ i32 │ #> ╞═════╪═════╪═══════╡ #> │ a ┆ 2.0 ┆ 5 │ #> │ a ┆ 1.0 ┆ 3 │ #> │ a ┆ 3.0 ┆ 1 │ #> │ b ┆ 5.0 ┆ 4 │ #> │ c ┆ 1.0 ┆ 2 │ #> └─────┴─────┴───────┘ arrange(pl_test, x1, -x2) #> shape: (5, 3) #> ┌─────┬─────┬───────┐ #> │ x1 ┆ x2 ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ i32 │ #> ╞═════╪═════╪═══════╡ #> │ a ┆ 3.0 ┆ 1 │ #> │ a ┆ 2.0 ┆ 5 │ #> │ a ┆ 1.0 ┆ 3 │ #> │ b ┆ 5.0 ┆ 4 │ #> │ c ┆ 1.0 ┆ 2 │ #> └─────┴─────┴───────┘ # if the data is grouped, you need to specify `.by_group = TRUE` to sort by # the groups first pl_test |> group_by(x1) |> arrange(-x2, .by_group = TRUE) #> shape: (5, 3) #> ┌─────┬─────┬───────┐ #> │ x1 ┆ x2 ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ i32 │ #> ╞═════╪═════╪═══════╡ #> │ a ┆ 3.0 ┆ 1 │ #> │ a ┆ 2.0 ┆ 5 │ #> │ a ┆ 1.0 ┆ 3 │ #> │ b ┆ 5.0 ┆ 4 │ #> │ c ┆ 1.0 ┆ 2 │ #> └─────┴─────┴───────┘ #> Groups [3]: x1 #> Maintain order: FALSE"},{"path":"https://tidypolars.etiennebacher.com/reference/as_tibble.tidypolars.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","title":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","text":"makes easier convert polars DataFrame LazyFrame tibble pipe workflow.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/as_tibble.tidypolars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","text":"","code":"# S3 method for class 'tidypolars' as_tibble(x, int64_conversion = polars::polars_options()$int64_conversion, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/as_tibble.tidypolars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","text":"x Polars Data/LazyFrame int64_conversion Int64 values handled converting polars object R? See documentation polars::.data.frame.RPolarsDataFrame. ... Options passed polars::.data.frame.RPolarsDataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/as_tibble.tidypolars.html","id":"about-int-","dir":"Reference","previous_headings":"","what":"About int64","title":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","text":"Int64 format accepted Polars natively R (package bit64 helps ). Since tidypolars simply wrapper around polars, behavior int64 values depend options set polars. Use options(polars.int64_conversion =) specify int64 variables handled. See documentation polars possible options.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/as_tibble.tidypolars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","text":"","code":"iris |> as_polars_df() |> filter(Sepal.Length > 6) |> as_tibble() #> # A tibble: 61 × 5 #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> #> 1 7 3.2 4.7 1.4 versicolor #> 2 6.4 3.2 4.5 1.5 versicolor #> 3 6.9 3.1 4.9 1.5 versicolor #> 4 6.5 2.8 4.6 1.5 versicolor #> 5 6.3 3.3 4.7 1.6 versicolor #> 6 6.6 2.9 4.6 1.3 versicolor #> 7 6.1 2.9 4.7 1.4 versicolor #> 8 6.7 3.1 4.4 1.4 versicolor #> 9 6.2 2.2 4.5 1.5 versicolor #> 10 6.1 2.8 4 1.3 versicolor #> # ℹ 51 more rows"},{"path":"https://tidypolars.etiennebacher.com/reference/bind_cols_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Append multiple Data/LazyFrames next to each other — bind_cols_polars","title":"Append multiple Data/LazyFrames next to each other — bind_cols_polars","text":"Append multiple Data/LazyFrames next ","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/bind_cols_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Append multiple Data/LazyFrames next to each other — bind_cols_polars","text":"","code":"bind_cols_polars(..., .name_repair = \"unique\")"},{"path":"https://tidypolars.etiennebacher.com/reference/bind_cols_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Append multiple Data/LazyFrames next to each other — bind_cols_polars","text":"... Polars DataFrames LazyFrames combine. argument can either Data/LazyFrame, list Data/LazyFrames. Columns matched name. Data/LazyFrames must number rows duplicated column names. .name_repair Can \"unique\", \"universal\", \"check_unique\", \"minimal\". See vctrs::vec_as_names() explanations value.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/bind_cols_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Append multiple Data/LazyFrames next to each other — bind_cols_polars","text":"","code":"p1 <- polars::pl$DataFrame( x = sample(letters, 20), y = sample(1:100, 20) ) p2 <- polars::pl$DataFrame( z = sample(letters, 20), w = sample(1:100, 20) ) bind_cols_polars(p1, p2) #> shape: (20, 4) #> ┌─────┬─────┬─────┬─────┐ #> │ x ┆ y ┆ z ┆ w │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ str ┆ i32 │ #> ╞═════╪═════╪═════╪═════╡ #> │ o ┆ 4 ┆ f ┆ 3 │ #> │ z ┆ 34 ┆ b ┆ 38 │ #> │ d ┆ 35 ┆ s ┆ 68 │ #> │ f ┆ 89 ┆ n ┆ 65 │ #> │ i ┆ 86 ┆ a ┆ 6 │ #> │ … ┆ … ┆ … ┆ … │ #> │ l ┆ 17 ┆ k ┆ 41 │ #> │ q ┆ 52 ┆ j ┆ 42 │ #> │ w ┆ 56 ┆ w ┆ 66 │ #> │ s ┆ 97 ┆ y ┆ 26 │ #> │ h ┆ 1 ┆ g ┆ 60 │ #> └─────┴─────┴─────┴─────┘ bind_cols_polars(list(p1, p2)) #> shape: (20, 4) #> ┌─────┬─────┬─────┬─────┐ #> │ x ┆ y ┆ z ┆ w │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ str ┆ i32 │ #> ╞═════╪═════╪═════╪═════╡ #> │ o ┆ 4 ┆ f ┆ 3 │ #> │ z ┆ 34 ┆ b ┆ 38 │ #> │ d ┆ 35 ┆ s ┆ 68 │ #> │ f ┆ 89 ┆ n ┆ 65 │ #> │ i ┆ 86 ┆ a ┆ 6 │ #> │ … ┆ … ┆ … ┆ … │ #> │ l ┆ 17 ┆ k ┆ 41 │ #> │ q ┆ 52 ┆ j ┆ 42 │ #> │ w ┆ 56 ┆ w ┆ 66 │ #> │ s ┆ 97 ┆ y ┆ 26 │ #> │ h ┆ 1 ┆ g ┆ 60 │ #> └─────┴─────┴─────┴─────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/bind_rows_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Stack multiple Data/LazyFrames on top of each other — bind_rows_polars","title":"Stack multiple Data/LazyFrames on top of each other — bind_rows_polars","text":"Stack multiple Data/LazyFrames top ","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/bind_rows_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stack multiple Data/LazyFrames on top of each other — bind_rows_polars","text":"","code":"bind_rows_polars(..., .id = NULL)"},{"path":"https://tidypolars.etiennebacher.com/reference/bind_rows_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stack multiple Data/LazyFrames on top of each other — bind_rows_polars","text":"... Polars DataFrames LazyFrames combine. argument can either Data/LazyFrame, list Data/LazyFrames. Columns matched name, missing columns filled NA. .id name optional identifier column. Provide string create output column identifies input. elements ... named, identifier use names. Otherwise, simple count.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/bind_rows_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Stack multiple Data/LazyFrames on top of each other — bind_rows_polars","text":"","code":"library(polars) p1 <- pl$DataFrame( x = c(\"a\", \"b\"), y = 1:2 ) p2 <- pl$DataFrame( y = 3:4, z = c(\"c\", \"d\") )$with_columns(pl$col(\"y\")$cast(pl$Int16)) bind_rows_polars(p1, p2) #> shape: (4, 3) #> ┌──────┬─────┬──────┐ #> │ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ str │ #> ╞══════╪═════╪══════╡ #> │ a ┆ 1 ┆ null │ #> │ b ┆ 2 ┆ null │ #> │ null ┆ 3 ┆ c │ #> │ null ┆ 4 ┆ d │ #> └──────┴─────┴──────┘ # this is equivalent bind_rows_polars(list(p1, p2)) #> shape: (4, 3) #> ┌──────┬─────┬──────┐ #> │ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ str │ #> ╞══════╪═════╪══════╡ #> │ a ┆ 1 ┆ null │ #> │ b ┆ 2 ┆ null │ #> │ null ┆ 3 ┆ c │ #> │ null ┆ 4 ┆ d │ #> └──────┴─────┴──────┘ # create an id colum bind_rows_polars(p1, p2, .id = \"id\") #> shape: (4, 4) #> ┌─────┬──────┬─────┬──────┐ #> │ id ┆ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ i32 ┆ str │ #> ╞═════╪══════╪═════╪══════╡ #> │ 1 ┆ a ┆ 1 ┆ null │ #> │ 1 ┆ b ┆ 2 ┆ null │ #> │ 2 ┆ null ┆ 3 ┆ c │ #> │ 2 ┆ null ┆ 4 ┆ d │ #> └─────┴──────┴─────┴──────┘ # create an id colum with named elements bind_rows_polars(p1 = p1, p2 = p2, .id = \"id\") #> shape: (4, 4) #> ┌─────┬──────┬─────┬──────┐ #> │ id ┆ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ i32 ┆ str │ #> ╞═════╪══════╪═════╪══════╡ #> │ p1 ┆ a ┆ 1 ┆ null │ #> │ p1 ┆ b ┆ 2 ┆ null │ #> │ p2 ┆ null ┆ 3 ┆ c │ #> │ p2 ┆ null ┆ 4 ┆ d │ #> └─────┴──────┴─────┴──────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/complete.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Complete a data frame with missing combinations of data — complete.RPolarsDataFrame","title":"Complete a data frame with missing combinations of data — complete.RPolarsDataFrame","text":"Turns implicit missing values explicit missing values. useful completing missing combinations data.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/complete.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Complete a data frame with missing combinations of data — complete.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' complete(data, ..., fill = list()) # S3 method for class 'RPolarsLazyFrame' complete(data, ..., fill = list())"},{"path":"https://tidypolars.etiennebacher.com/reference/complete.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Complete a data frame with missing combinations of data — complete.RPolarsDataFrame","text":"data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. fill named list variable supplies single value use instead NA missing combinations.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/complete.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Complete a data frame with missing combinations of data — complete.RPolarsDataFrame","text":"","code":"df <- polars::pl$DataFrame( group = c(1:2, 1, 2), item_id = c(1:2, 2, 3), item_name = c(\"a\", \"a\", \"b\", \"b\"), value1 = c(1, NA, 3, 4), value2 = 4:7 ) df #> shape: (4, 5) #> ┌───────┬─────────┬───────────┬────────┬────────┐ #> │ group ┆ item_id ┆ item_name ┆ value1 ┆ value2 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ str ┆ f64 ┆ i32 │ #> ╞═══════╪═════════╪═══════════╪════════╪════════╡ #> │ 1.0 ┆ 1.0 ┆ a ┆ 1.0 ┆ 4 │ #> │ 2.0 ┆ 2.0 ┆ a ┆ null ┆ 5 │ #> │ 1.0 ┆ 2.0 ┆ b ┆ 3.0 ┆ 6 │ #> │ 2.0 ┆ 3.0 ┆ b ┆ 4.0 ┆ 7 │ #> └───────┴─────────┴───────────┴────────┴────────┘ df |> complete(group, item_id, item_name) #> shape: (12, 5) #> ┌───────┬─────────┬───────────┬────────┬────────┐ #> │ group ┆ item_id ┆ item_name ┆ value1 ┆ value2 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ str ┆ f64 ┆ i32 │ #> ╞═══════╪═════════╪═══════════╪════════╪════════╡ #> │ 1.0 ┆ 1.0 ┆ a ┆ 1.0 ┆ 4 │ #> │ 1.0 ┆ 1.0 ┆ b ┆ null ┆ null │ #> │ 1.0 ┆ 2.0 ┆ a ┆ null ┆ null │ #> │ 1.0 ┆ 2.0 ┆ b ┆ 3.0 ┆ 6 │ #> │ 1.0 ┆ 3.0 ┆ a ┆ null ┆ null │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 2.0 ┆ 1.0 ┆ b ┆ null ┆ null │ #> │ 2.0 ┆ 2.0 ┆ a ┆ null ┆ 5 │ #> │ 2.0 ┆ 2.0 ┆ b ┆ null ┆ null │ #> │ 2.0 ┆ 3.0 ┆ a ┆ null ┆ null │ #> │ 2.0 ┆ 3.0 ┆ b ┆ 4.0 ┆ 7 │ #> └───────┴─────────┴───────────┴────────┴────────┘ df |> complete( group, item_id, item_name, fill = list(value1 = 0, value2 = 99) ) #> shape: (12, 5) #> ┌───────┬─────────┬───────────┬────────┬────────┐ #> │ group ┆ item_id ┆ item_name ┆ value1 ┆ value2 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ str ┆ f64 ┆ f64 │ #> ╞═══════╪═════════╪═══════════╪════════╪════════╡ #> │ 1.0 ┆ 1.0 ┆ a ┆ 1.0 ┆ 4.0 │ #> │ 1.0 ┆ 1.0 ┆ b ┆ 0.0 ┆ 99.0 │ #> │ 1.0 ┆ 2.0 ┆ a ┆ 0.0 ┆ 99.0 │ #> │ 1.0 ┆ 2.0 ┆ b ┆ 3.0 ┆ 6.0 │ #> │ 1.0 ┆ 3.0 ┆ a ┆ 0.0 ┆ 99.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 2.0 ┆ 1.0 ┆ b ┆ 0.0 ┆ 99.0 │ #> │ 2.0 ┆ 2.0 ┆ a ┆ 0.0 ┆ 5.0 │ #> │ 2.0 ┆ 2.0 ┆ b ┆ 0.0 ┆ 99.0 │ #> │ 2.0 ┆ 3.0 ┆ a ┆ 0.0 ┆ 99.0 │ #> │ 2.0 ┆ 3.0 ┆ b ┆ 4.0 ┆ 7.0 │ #> └───────┴─────────┴───────────┴────────┴────────┘ df |> group_by(group, maintain_order = TRUE) |> complete(item_id, item_name) #> shape: (8, 5) #> ┌───────┬─────────┬───────────┬────────┬────────┐ #> │ group ┆ item_id ┆ item_name ┆ value1 ┆ value2 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ str ┆ f64 ┆ i32 │ #> ╞═══════╪═════════╪═══════════╪════════╪════════╡ #> │ 1.0 ┆ 1.0 ┆ a ┆ 1.0 ┆ 4 │ #> │ 1.0 ┆ 1.0 ┆ b ┆ null ┆ null │ #> │ 1.0 ┆ 2.0 ┆ a ┆ null ┆ null │ #> │ 1.0 ┆ 2.0 ┆ b ┆ 3.0 ┆ 6 │ #> │ 2.0 ┆ 2.0 ┆ a ┆ null ┆ 5 │ #> │ 2.0 ┆ 2.0 ┆ b ┆ null ┆ null │ #> │ 2.0 ┆ 3.0 ┆ a ┆ null ┆ null │ #> │ 2.0 ┆ 3.0 ┆ b ┆ 4.0 ┆ 7 │ #> └───────┴─────────┴───────────┴────────┴────────┘ #> Groups [2]: group #> Maintain order: TRUE"},{"path":"https://tidypolars.etiennebacher.com/reference/compute.RPolarsLazyFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Collect a LazyFrame — compute.RPolarsLazyFrame","title":"Collect a LazyFrame — compute.RPolarsLazyFrame","text":"compute() checks query, optimizes background, runs . output Polars DataFrame. collect() similar compute() converts output R data.frame, consumes memory. tidypolars 0.7.0, collect() used collect LazyFrame Polars DataFrame. usage still valid now change 0.8.0 automatically convert DataFrame data.frame. Use compute() Polars DataFrame output.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/compute.RPolarsLazyFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collect a LazyFrame — compute.RPolarsLazyFrame","text":"","code":"# S3 method for class 'RPolarsLazyFrame' compute( x, ..., type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, comm_subplan_elim = TRUE, comm_subexpr_elim = TRUE, cluster_with_columns = TRUE, no_optimization = FALSE, streaming = FALSE, collect_in_background = FALSE ) # S3 method for class 'RPolarsLazyFrame' collect( x, ..., type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, comm_subplan_elim = TRUE, comm_subexpr_elim = TRUE, cluster_with_columns = TRUE, no_optimization = FALSE, streaming = FALSE, collect_in_background = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/compute.RPolarsLazyFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collect a LazyFrame — compute.RPolarsLazyFrame","text":"x Polars LazyFrame ... Dots empty. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). comm_subplan_elim Cache branching subplans occur self-joins unions (default TRUE). comm_subexpr_elim Cache common subexpressions (default TRUE). cluster_with_columns Combine sequential independent calls $with_columns(). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE. streaming Run parts query streaming fashion (alpha state). Default FALSE. collect_in_background Detach query R session. Computation start background. Get handle later can converted resulting DataFrame. Useful interactive mode lock R session (default FALSE).","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/reference/compute.RPolarsLazyFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collect a LazyFrame — compute.RPolarsLazyFrame","text":"","code":"dat_lazy <- polars::as_polars_df(iris)$lazy() compute(dat_lazy) #> shape: (150, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ # you can build a query and add compute() as the last piece dat_lazy |> select(starts_with(\"Sepal\")) |> filter(between(Sepal.Length, 5, 6)) |> compute() #> shape: (67, 2) #> ┌──────────────┬─────────────┐ #> │ Sepal.Length ┆ Sepal.Width │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════════════╪═════════════╡ #> │ 5.1 ┆ 3.5 │ #> │ 5.0 ┆ 3.6 │ #> │ 5.4 ┆ 3.9 │ #> │ 5.0 ┆ 3.4 │ #> │ 5.4 ┆ 3.7 │ #> │ … ┆ … │ #> │ 6.0 ┆ 2.2 │ #> │ 5.6 ┆ 2.8 │ #> │ 6.0 ┆ 3.0 │ #> │ 5.8 ┆ 2.7 │ #> │ 5.9 ┆ 3.0 │ #> └──────────────┴─────────────┘ # call collect() instead to return a data.frame (note that this is more # expensive than compute()) dat_lazy |> select(starts_with(\"Sepal\")) |> filter(between(Sepal.Length, 5, 6)) |> collect() #> Sepal.Length Sepal.Width #> 1 5.1 3.5 #> 2 5.0 3.6 #> 3 5.4 3.9 #> 4 5.0 3.4 #> 5 5.4 3.7 #> 6 5.8 4.0 #> 7 5.7 4.4 #> 8 5.4 3.9 #> 9 5.1 3.5 #> 10 5.7 3.8 #> 11 5.1 3.8 #> 12 5.4 3.4 #> 13 5.1 3.7 #> 14 5.1 3.3 #> 15 5.0 3.0 #> 16 5.0 3.4 #> 17 5.2 3.5 #> 18 5.2 3.4 #> 19 5.4 3.4 #> 20 5.2 4.1 #> 21 5.5 4.2 #> 22 5.0 3.2 #> 23 5.5 3.5 #> 24 5.1 3.4 #> 25 5.0 3.5 #> 26 5.0 3.5 #> 27 5.1 3.8 #> 28 5.1 3.8 #> 29 5.3 3.7 #> 30 5.0 3.3 #> 31 5.5 2.3 #> 32 5.7 2.8 #> 33 5.2 2.7 #> 34 5.0 2.0 #> 35 5.9 3.0 #> 36 6.0 2.2 #> 37 5.6 2.9 #> 38 5.6 3.0 #> 39 5.8 2.7 #> 40 5.6 2.5 #> 41 5.9 3.2 #> 42 6.0 2.9 #> 43 5.7 2.6 #> 44 5.5 2.4 #> 45 5.5 2.4 #> 46 5.8 2.7 #> 47 6.0 2.7 #> 48 5.4 3.0 #> 49 6.0 3.4 #> 50 5.6 3.0 #> 51 5.5 2.5 #> 52 5.5 2.6 #> 53 5.8 2.6 #> 54 5.0 2.3 #> 55 5.6 2.7 #> 56 5.7 3.0 #> 57 5.7 2.9 #> 58 5.1 2.5 #> 59 5.7 2.8 #> 60 5.8 2.7 #> 61 5.7 2.5 #> 62 5.8 2.8 #> 63 6.0 2.2 #> 64 5.6 2.8 #> 65 6.0 3.0 #> 66 5.8 2.7 #> 67 5.9 3.0"},{"path":"https://tidypolars.etiennebacher.com/reference/count.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Count the observations in each group — count.RPolarsDataFrame","title":"Count the observations in each group — count.RPolarsDataFrame","text":"Count observations group","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/count.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count the observations in each group — count.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' count(x, ..., sort = FALSE, name = \"n\") # S3 method for class 'RPolarsLazyFrame' count(x, ..., sort = FALSE, name = \"n\") # S3 method for class 'RPolarsDataFrame' add_count(x, ..., sort = FALSE, name = \"n\") # S3 method for class 'RPolarsLazyFrame' add_count(x, ..., sort = FALSE, name = \"n\")"},{"path":"https://tidypolars.etiennebacher.com/reference/count.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count the observations in each group — count.RPolarsDataFrame","text":"x Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. sort TRUE, show largest groups top. name Name new column.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/count.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count the observations in each group — count.RPolarsDataFrame","text":"","code":"test <- polars::as_polars_df(mtcars) count(test, cyl) #> shape: (3, 2) #> ┌─────┬─────┐ #> │ cyl ┆ n │ #> │ --- ┆ --- │ #> │ f64 ┆ u32 │ #> ╞═════╪═════╡ #> │ 4.0 ┆ 11 │ #> │ 6.0 ┆ 7 │ #> │ 8.0 ┆ 14 │ #> └─────┴─────┘ count(test, cyl, am) #> shape: (6, 3) #> ┌─────┬─────┬─────┐ #> │ cyl ┆ am ┆ n │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ u32 │ #> ╞═════╪═════╪═════╡ #> │ 4.0 ┆ 0.0 ┆ 3 │ #> │ 4.0 ┆ 1.0 ┆ 8 │ #> │ 6.0 ┆ 0.0 ┆ 4 │ #> │ 6.0 ┆ 1.0 ┆ 3 │ #> │ 8.0 ┆ 0.0 ┆ 12 │ #> │ 8.0 ┆ 1.0 ┆ 2 │ #> └─────┴─────┴─────┘ count(test, cyl, am, sort = TRUE, name = \"count\") #> shape: (6, 3) #> ┌─────┬─────┬───────┐ #> │ cyl ┆ am ┆ count │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ u32 │ #> ╞═════╪═════╪═══════╡ #> │ 8.0 ┆ 0.0 ┆ 12 │ #> │ 4.0 ┆ 1.0 ┆ 8 │ #> │ 6.0 ┆ 0.0 ┆ 4 │ #> │ 4.0 ┆ 0.0 ┆ 3 │ #> │ 6.0 ┆ 1.0 ┆ 3 │ #> │ 8.0 ┆ 1.0 ┆ 2 │ #> └─────┴─────┴───────┘ add_count(test, cyl, am, sort = TRUE, name = \"count\") #> shape: (32, 12) #> ┌──────┬─────┬───────┬───────┬───┬─────┬──────┬──────┬───────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ am ┆ gear ┆ carb ┆ count │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ u32 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪══════╪══════╪═══════╡ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 2.0 ┆ 12 │ #> │ 14.3 ┆ 8.0 ┆ 360.0 ┆ 245.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 4.0 ┆ 12 │ #> │ 16.4 ┆ 8.0 ┆ 275.8 ┆ 180.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 3.0 ┆ 12 │ #> │ 17.3 ┆ 8.0 ┆ 275.8 ┆ 180.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 3.0 ┆ 12 │ #> │ 15.2 ┆ 8.0 ┆ 275.8 ┆ 180.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 3.0 ┆ 12 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 22.8 ┆ 4.0 ┆ 140.8 ┆ 95.0 ┆ … ┆ 0.0 ┆ 4.0 ┆ 2.0 ┆ 3 │ #> │ 21.5 ┆ 4.0 ┆ 120.1 ┆ 97.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 1.0 ┆ 3 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 6.0 ┆ 3 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 4.0 ┆ 2 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 8.0 ┆ 2 │ #> └──────┴─────┴───────┴───────┴───┴─────┴──────┴──────┴───────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/cross_join.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Cross join — cross_join.RPolarsDataFrame","title":"Cross join — cross_join.RPolarsDataFrame","text":"Cross joins match row x every row y, resulting dataset nrow(x) * nrow(y) rows.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/cross_join.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cross join — cross_join.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' cross_join(x, y, ..., suffix = c(\".x\", \".y\")) # S3 method for class 'RPolarsLazyFrame' cross_join(x, y, ..., suffix = c(\".x\", \".y\"))"},{"path":"https://tidypolars.etiennebacher.com/reference/cross_join.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cross join — cross_join.RPolarsDataFrame","text":"x, y Two Polars Data/LazyFrames ... Dots empty. suffix non-joined duplicate variables x y, suffixes added output disambiguate . character vector length 2.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/cross_join.RPolarsDataFrame.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Cross join — cross_join.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/cross_join.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cross join — cross_join.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame( origin = c(\"ALG\", \"FRA\", \"GER\"), year = c(2020, 2020, 2021) ) test2 <- polars::pl$DataFrame( destination = c(\"USA\", \"JPN\", \"BRA\"), language = c(\"english\", \"japanese\", \"portuguese\") ) test #> shape: (3, 2) #> ┌────────┬────────┐ #> │ origin ┆ year │ #> │ --- ┆ --- │ #> │ str ┆ f64 │ #> ╞════════╪════════╡ #> │ ALG ┆ 2020.0 │ #> │ FRA ┆ 2020.0 │ #> │ GER ┆ 2021.0 │ #> └────────┴────────┘ test2 #> shape: (3, 2) #> ┌─────────────┬────────────┐ #> │ destination ┆ language │ #> │ --- ┆ --- │ #> │ str ┆ str │ #> ╞═════════════╪════════════╡ #> │ USA ┆ english │ #> │ JPN ┆ japanese │ #> │ BRA ┆ portuguese │ #> └─────────────┴────────────┘ cross_join(test, test2) #> shape: (9, 4) #> ┌────────┬────────┬─────────────┬────────────┐ #> │ origin ┆ year ┆ destination ┆ language │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ str ┆ str │ #> ╞════════╪════════╪═════════════╪════════════╡ #> │ ALG ┆ 2020.0 ┆ USA ┆ english │ #> │ ALG ┆ 2020.0 ┆ JPN ┆ japanese │ #> │ ALG ┆ 2020.0 ┆ BRA ┆ portuguese │ #> │ FRA ┆ 2020.0 ┆ USA ┆ english │ #> │ FRA ┆ 2020.0 ┆ JPN ┆ japanese │ #> │ FRA ┆ 2020.0 ┆ BRA ┆ portuguese │ #> │ GER ┆ 2021.0 ┆ USA ┆ english │ #> │ GER ┆ 2021.0 ┆ JPN ┆ japanese │ #> │ GER ┆ 2021.0 ┆ BRA ┆ portuguese │ #> └────────┴────────┴─────────────┴────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/describe.html","id":null,"dir":"Reference","previous_headings":"","what":"Summary statistics for a Polars DataFrame — describe","title":"Summary statistics for a Polars DataFrame — describe","text":"function deprecated tidypolars 0.10.0, removed future update. Use summary() arguments instead.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/describe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summary statistics for a Polars DataFrame — describe","text":"","code":"describe(.data, percentiles = c(0.25, 0.75))"},{"path":"https://tidypolars.etiennebacher.com/reference/describe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summary statistics for a Polars DataFrame — describe","text":".data Polars DataFrame. percentiles One percentiles include summary statistics. values must 0 1 (NULL ignored).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/describe_plan.html","id":null,"dir":"Reference","previous_headings":"","what":"Show the optimized and non-optimized query plans — describe_plan","title":"Show the optimized and non-optimized query plans — describe_plan","text":"functions deprecated tidypolars 0.10.0, removed future update. Use explain() optimized = FALSE recover output describe_plan(), optimized = TRUE (default) get output describe_optimized_plan().","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/describe_plan.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Show the optimized and non-optimized query plans — describe_plan","text":"","code":"describe_plan(.data) describe_optimized_plan(.data)"},{"path":"https://tidypolars.etiennebacher.com/reference/describe_plan.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Show the optimized and non-optimized query plans — describe_plan","text":".data Polars LazyFrame","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/distinct.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Remove or keep only duplicated rows in a Data/LazyFrame — distinct.RPolarsDataFrame","title":"Remove or keep only duplicated rows in a Data/LazyFrame — distinct.RPolarsDataFrame","text":"default, duplicates looked variables. possible specify subset variables duplicates looked . also possible keep either first occurrence, last occurence remove duplicates.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/distinct.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Remove or keep only duplicated rows in a Data/LazyFrame — distinct.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' distinct(.data, ..., keep = \"first\", maintain_order = TRUE) # S3 method for class 'RPolarsLazyFrame' distinct(.data, ..., keep = \"first\", maintain_order = TRUE) duplicated_rows(.data, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/distinct.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Remove or keep only duplicated rows in a Data/LazyFrame — distinct.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. keep Either \"first\" (keep first occurrence duplicated row), \"last\" (last occurrence) \"none\" (remove ofccurences duplicated rows). maintain_order Maintain row order. default can slow process large datasets prevents use streaming.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/distinct.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Remove or keep only duplicated rows in a Data/LazyFrame — distinct.RPolarsDataFrame","text":"","code":"pl_test <- polars::pl$DataFrame( iso_o = c(rep(c(\"AA\", \"AB\"), each = 2), \"AC\", \"DC\"), iso_d = rep(c(\"BA\", \"BB\", \"BC\"), each = 2), value = c(2, 2, 3, 4, 5, 6) ) distinct(pl_test) #> shape: (5, 3) #> ┌───────┬───────┬───────┐ #> │ iso_o ┆ iso_d ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ f64 │ #> ╞═══════╪═══════╪═══════╡ #> │ AA ┆ BA ┆ 2.0 │ #> │ AB ┆ BB ┆ 3.0 │ #> │ AB ┆ BB ┆ 4.0 │ #> │ AC ┆ BC ┆ 5.0 │ #> │ DC ┆ BC ┆ 6.0 │ #> └───────┴───────┴───────┘ distinct(pl_test, iso_o) #> shape: (4, 3) #> ┌───────┬───────┬───────┐ #> │ iso_o ┆ iso_d ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ f64 │ #> ╞═══════╪═══════╪═══════╡ #> │ AA ┆ BA ┆ 2.0 │ #> │ AB ┆ BB ┆ 3.0 │ #> │ AC ┆ BC ┆ 5.0 │ #> │ DC ┆ BC ┆ 6.0 │ #> └───────┴───────┴───────┘ duplicated_rows(pl_test) #> shape: (2, 3) #> ┌───────┬───────┬───────┐ #> │ iso_o ┆ iso_d ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ f64 │ #> ╞═══════╪═══════╪═══════╡ #> │ AA ┆ BA ┆ 2.0 │ #> │ AA ┆ BA ┆ 2.0 │ #> └───────┴───────┴───────┘ duplicated_rows(pl_test, iso_o, iso_d) #> shape: (4, 3) #> ┌───────┬───────┬───────┐ #> │ iso_o ┆ iso_d ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ f64 │ #> ╞═══════╪═══════╪═══════╡ #> │ AA ┆ BA ┆ 2.0 │ #> │ AA ┆ BA ┆ 2.0 │ #> │ AB ┆ BB ┆ 3.0 │ #> │ AB ┆ BB ┆ 4.0 │ #> └───────┴───────┴───────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/drop_na.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Drop missing values — drop_na.RPolarsDataFrame","title":"Drop missing values — drop_na.RPolarsDataFrame","text":"default, drop rows contain missing values. possible specify subset variables missing values variables considered.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/drop_na.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drop missing values — drop_na.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' drop_na(data, ...) # S3 method for class 'RPolarsLazyFrame' drop_na(data, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/drop_na.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Drop missing values — drop_na.RPolarsDataFrame","text":"data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/drop_na.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Drop missing values — drop_na.RPolarsDataFrame","text":"","code":"tmp <- mtcars tmp[1:3, \"mpg\"] <- NA tmp[4, \"hp\"] <- NA pl_tmp <- polars::pl$DataFrame(tmp) #> Warning: Passing a `data.frame` or `RPolarsDataFrame` to `pl$DataFrame()` is deprecated and will be removed in the future. Use `as_polars_df()` instead. drop_na(pl_tmp) #> shape: (28, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ 18.1 ┆ 6.0 ┆ 225.0 ┆ 105.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 14.3 ┆ 8.0 ┆ 360.0 ┆ 245.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 4.0 │ #> │ 24.4 ┆ 4.0 ┆ 146.7 ┆ 62.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ 22.8 ┆ 4.0 ┆ 140.8 ┆ 95.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘ drop_na(pl_tmp, hp, mpg) #> shape: (28, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ 18.1 ┆ 6.0 ┆ 225.0 ┆ 105.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 14.3 ┆ 8.0 ┆ 360.0 ┆ 245.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 4.0 │ #> │ 24.4 ┆ 4.0 ┆ 146.7 ┆ 62.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ 22.8 ┆ 4.0 ┆ 140.8 ┆ 95.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/explain.RPolarsLazyFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Show the optimized and non-optimized query plans — explain.RPolarsLazyFrame","title":"Show the optimized and non-optimized query plans — explain.RPolarsLazyFrame","text":"function available LazyFrames . default, explain() shows query plan optimized run Polars. Setting optimized = FALSE shows query plan -, without optimization done, query performed. Note plans read bottom top.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/explain.RPolarsLazyFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Show the optimized and non-optimized query plans — explain.RPolarsLazyFrame","text":"","code":"# S3 method for class 'RPolarsLazyFrame' explain(x, optimized = TRUE, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/explain.RPolarsLazyFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Show the optimized and non-optimized query plans — explain.RPolarsLazyFrame","text":"x Polars LazyFrame. optimized Logical. TRUE (default), show query optimized Polars. Otherwise, show initial query. ... Ignored.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/explain.RPolarsLazyFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Show the optimized and non-optimized query plans — explain.RPolarsLazyFrame","text":"","code":"query <- mtcars |> as_polars_lf() |> arrange(drat) |> filter(cyl == 3) |> select(mpg) # unoptimized query plan: no_opt <- explain(query, optimized = FALSE) no_opt #> [1] \" SELECT [col(\\\"mpg\\\")] FROM\\n FILTER [(col(\\\"cyl\\\")) == (3.0)] FROM\\n SORT BY [col(\\\"drat\\\")]\\n DF [\\\"mpg\\\", \\\"cyl\\\", \\\"disp\\\", \\\"hp\\\"]; PROJECT */11 COLUMNS; SELECTION: None\" # better printing with cat(): cat(no_opt) #> SELECT [col(\"mpg\")] FROM #> FILTER [(col(\"cyl\")) == (3.0)] FROM #> SORT BY [col(\"drat\")] #> DF [\"mpg\", \"cyl\", \"disp\", \"hp\"]; PROJECT */11 COLUMNS; SELECTION: None # optimized query run by polars cat(explain(query)) #> simple π 1/3 [\"mpg\"] #> SORT BY [col(\"drat\")] #> DF [\"mpg\", \"cyl\", \"disp\", \"hp\"]; PROJECT 3/11 COLUMNS; SELECTION: [(col(\"cyl\")) == (3.0)]"},{"path":"https://tidypolars.etiennebacher.com/reference/fetch.html","id":null,"dir":"Reference","previous_headings":"","what":"Fetch n rows of a LazyFrame — fetch","title":"Fetch n rows of a LazyFrame — fetch","text":"Fetch way collect first n rows LazyFrame. mainly used test query runs expected subset data using collect() full query. Note fetching n rows mean output actually contain n rows, see section 'Details' information.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/fetch.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fetch n rows of a LazyFrame — fetch","text":"","code":"fetch( .data, n_rows = 500, type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, comm_subplan_elim = TRUE, comm_subexpr_elim = TRUE, cluster_with_columns = TRUE, no_optimization = FALSE, streaming = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/fetch.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fetch n rows of a LazyFrame — fetch","text":".data Polars LazyFrame n_rows Number rows fetch. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). comm_subplan_elim Cache branching subplans occur self-joins unions (default TRUE). comm_subexpr_elim Cache common subexpressions (default TRUE). cluster_with_columns Combine sequential independent calls $with_columns(). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE. streaming Run parts query streaming fashion (alpha state). Default FALSE.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/fetch.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fetch n rows of a LazyFrame — fetch","text":"parameter n_rows indicates many rows LazyFrame used beginning query, guarantee n_rows returned. example, query contains filter join operations datasets, final number rows can lower n_rows. hand, appending rows query can lead output rows n_rows.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/reference/fetch.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fetch n rows of a LazyFrame — fetch","text":"","code":"dat_lazy <- polars::as_polars_df(iris)$lazy() # this will return 30 rows fetch(dat_lazy, 30) #> shape: (30, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬─────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 5.0 ┆ 3.0 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.4 ┆ 1.6 ┆ 0.4 ┆ setosa │ #> │ 5.2 ┆ 3.5 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.2 ┆ 3.4 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴─────────┘ # this will return less than 30 rows because there are less than 30 matches # for this filter in the whole dataset dat_lazy |> filter(Sepal.Length > 7.0) |> fetch(30) #> shape: (12, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 7.1 ┆ 3.0 ┆ 5.9 ┆ 2.1 ┆ virginica │ #> │ 7.6 ┆ 3.0 ┆ 6.6 ┆ 2.1 ┆ virginica │ #> │ 7.3 ┆ 2.9 ┆ 6.3 ┆ 1.8 ┆ virginica │ #> │ 7.2 ┆ 3.6 ┆ 6.1 ┆ 2.5 ┆ virginica │ #> │ 7.7 ┆ 3.8 ┆ 6.7 ┆ 2.2 ┆ virginica │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 7.2 ┆ 3.2 ┆ 6.0 ┆ 1.8 ┆ virginica │ #> │ 7.2 ┆ 3.0 ┆ 5.8 ┆ 1.6 ┆ virginica │ #> │ 7.4 ┆ 2.8 ┆ 6.1 ┆ 1.9 ┆ virginica │ #> │ 7.9 ┆ 3.8 ┆ 6.4 ┆ 2.0 ┆ virginica │ #> │ 7.7 ┆ 3.0 ┆ 6.1 ┆ 2.3 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/fill.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","title":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","text":"Fills missing values selected columns using next previous entry. useful common output format values repeated, recorded change.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/fill.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' fill(data, ..., .direction = c(\"down\", \"up\", \"downup\", \"updown\"))"},{"path":"https://tidypolars.etiennebacher.com/reference/fill.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","text":"data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. .direction Direction fill missing values. Either \"\" (default), \"\", \"downup\" (.e. first ) \"updown\" (first ).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/fill.RPolarsDataFrame.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","text":"grouped Data/LazyFrames, fill() applied within group, meaning fill across group boundaries.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/fill.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","text":"","code":"pl_test <- polars::pl$DataFrame(x = c(NA, 1), y = c(2, NA)) fill(pl_test, everything(), .direction = \"down\") #> shape: (2, 2) #> ┌──────┬─────┐ #> │ x ┆ y │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════╪═════╡ #> │ null ┆ 2.0 │ #> │ 1.0 ┆ 2.0 │ #> └──────┴─────┘ fill(pl_test, everything(), .direction = \"up\") #> shape: (2, 2) #> ┌─────┬──────┐ #> │ x ┆ y │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞═════╪══════╡ #> │ 1.0 ┆ 2.0 │ #> │ 1.0 ┆ null │ #> └─────┴──────┘ # with grouped data, it doesn't use values from other groups pl_grouped <- polars::pl$DataFrame( grp = rep(c(\"A\", \"B\"), each = 3), x = c(1, NA, NA, NA, 2, NA), y = c(3, NA, 4, NA, 3, 1) ) |> group_by(grp) fill(pl_grouped, x, y, .direction = \"down\") #> shape: (6, 3) #> ┌─────┬──────┬──────┐ #> │ grp ┆ x ┆ y │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ f64 │ #> ╞═════╪══════╪══════╡ #> │ A ┆ 1.0 ┆ 3.0 │ #> │ A ┆ 1.0 ┆ 3.0 │ #> │ A ┆ 1.0 ┆ 4.0 │ #> │ B ┆ null ┆ null │ #> │ B ┆ 2.0 ┆ 3.0 │ #> │ B ┆ 2.0 ┆ 1.0 │ #> └─────┴──────┴──────┘ #> Groups [2]: grp #> Maintain order: FALSE"},{"path":"https://tidypolars.etiennebacher.com/reference/filter.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Keep rows that match a condition — filter.RPolarsDataFrame","title":"Keep rows that match a condition — filter.RPolarsDataFrame","text":"function used subset data frame, retaining rows satisfy conditions. retained, row must produce value TRUE conditions. Note condition evaluates NA row dropped, unlike base subsetting [.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/filter.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Keep rows that match a condition — filter.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' filter(.data, ..., .by = NULL) # S3 method for class 'RPolarsLazyFrame' filter(.data, ..., .by = NULL)"},{"path":"https://tidypolars.etiennebacher.com/reference/filter.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Keep rows that match a condition — filter.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Expressions return logical value, defined terms variables data. multiple expressions included, combined & operator. rows conditions evaluate TRUE kept. .Optionally, selection columns group just operation, functioning alternative group_by(). group order maintained, use group_by() want control .","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/filter.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Keep rows that match a condition — filter.RPolarsDataFrame","text":"","code":"pl_iris <- polars::as_polars_df(iris) filter(pl_iris, Sepal.Length < 5, Species == \"setosa\") #> shape: (20, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬─────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═════════╡ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.4 ┆ 1.4 ┆ 0.3 ┆ setosa │ #> │ 4.4 ┆ 2.9 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4.4 ┆ 3.0 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.5 ┆ 2.3 ┆ 1.3 ┆ 0.3 ┆ setosa │ #> │ 4.4 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.8 ┆ 3.0 ┆ 1.4 ┆ 0.3 ┆ setosa │ #> │ 4.6 ┆ 3.2 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴─────────┘ filter(pl_iris, Sepal.Length < Sepal.Width + Petal.Length) #> shape: (115, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.4 ┆ 3.9 ┆ 1.7 ┆ 0.4 ┆ setosa │ #> │ 4.6 ┆ 3.4 ┆ 1.4 ┆ 0.3 ┆ setosa │ #> │ 4.8 ┆ 3.4 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 5.7 ┆ 4.4 ┆ 1.5 ┆ 0.4 ┆ setosa │ #> │ 5.1 ┆ 3.8 ┆ 1.5 ┆ 0.3 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ filter(pl_iris, Species == \"setosa\" | is.na(Species)) #> shape: (50, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬─────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4.8 ┆ 3.0 ┆ 1.4 ┆ 0.3 ┆ setosa │ #> │ 5.1 ┆ 3.8 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.2 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 5.3 ┆ 3.7 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.3 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴─────────┘ iris2 <- iris iris2$Species <- as.character(iris2$Species) iris2 |> as_polars_df() |> filter(Species %in% c(\"setosa\", \"virginica\")) #> shape: (100, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ str │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ # filter by group pl_iris |> group_by(Species) |> filter(Sepal.Length == max(Sepal.Length)) |> ungroup() #> shape: (3, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪════════════╡ #> │ 5.8 ┆ 4.0 ┆ 1.2 ┆ 0.2 ┆ setosa │ #> │ 7.0 ┆ 3.2 ┆ 4.7 ┆ 1.4 ┆ versicolor │ #> │ 7.9 ┆ 3.8 ┆ 6.4 ┆ 2.0 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴────────────┘ # an alternative syntax for grouping is to use `.by` pl_iris |> filter(Sepal.Length == max(Sepal.Length), .by = Species) #> shape: (3, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪════════════╡ #> │ 5.8 ┆ 4.0 ┆ 1.2 ┆ 0.2 ┆ setosa │ #> │ 7.0 ┆ 3.2 ┆ 4.7 ┆ 1.4 ┆ versicolor │ #> │ 7.9 ┆ 3.8 ┆ 6.4 ┆ 2.0 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/from_csv.html","id":null,"dir":"Reference","previous_headings":"","what":"Import data from CSV file(s) — from_csv","title":"Import data from CSV file(s) — from_csv","text":"read_csv_polars() imports data Polars DataFrame. scan_csv_polars() imports data Polars LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_csv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import data from CSV file(s) — from_csv","text":"","code":"read_csv_polars( source, ..., has_header = TRUE, separator = \",\", comment_prefix = NULL, quote_char = \"\\\"\", skip_rows = 0, dtypes = NULL, null_values = NULL, ignore_errors = FALSE, cache = FALSE, infer_schema_length = 100, n_rows = NULL, encoding = \"utf8\", low_memory = FALSE, rechunk = TRUE, skip_rows_after_header = 0, row_index_name = NULL, row_index_offset = 0, try_parse_dates = FALSE, eol_char = \"\\n\", raise_if_empty = TRUE, truncate_ragged_lines = FALSE, reuse_downloaded = TRUE ) scan_csv_polars( source, ..., has_header = TRUE, separator = \",\", comment_prefix = NULL, quote_char = \"\\\"\", skip_rows = 0, dtypes = NULL, null_values = NULL, ignore_errors = FALSE, cache = FALSE, infer_schema_length = 100, n_rows = NULL, encoding = \"utf8\", low_memory = FALSE, rechunk = TRUE, skip_rows_after_header = 0, row_index_name = NULL, row_index_offset = 0, try_parse_dates = FALSE, eol_char = \"\\n\", raise_if_empty = TRUE, truncate_ragged_lines = FALSE, reuse_downloaded = TRUE )"},{"path":"https://tidypolars.etiennebacher.com/reference/from_csv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import data from CSV file(s) — from_csv","text":"source Path file URL. possible provide multiple paths provided CSV files schema. possible provide several URLs. ... Ignored. has_header Indicate first row dataset header .FALSE, column names autogenerated following format: \"column_x\" x enumeration every column dataset starting 1. separator Single byte character use separator file. comment_prefix string, can 5 symbols length, used indicate start comment line. instance, can set # //. quote_char Single byte character used quoting. Set NULL turn special handling escaping quotes. skip_rows Start reading particular number rows. header parsed offset. dtypes Named list column names - dtypes dtype - column names. list used reading overwrite dtypes. Supported types far : \"Boolean\" \"logical\" DataType::Boolean, \"Categorical\" \"factor\" DataType::Categorical, \"Float32\" \"double\" DataType::Float32, \"Float64\" \"float64\" DataType::Float64, \"Int32\" \"integer\" DataType::Int32, \"Int64\" \"integer64\" DataType::Int64, \"String\" \"character\" DataType::String, null_values Values interpret NA values. Can : character vector: values match one values vector NA; named list column names null values. ignore_errors Keep reading file even lines yield errors. can also use infer_schema_length = 0 read columns UTF8 check values might cause issue. cache Cache result reading. infer_schema_length Maximum number rows read infer column types. set 0, columns read UTF-8. NULL, full table scan done (slow). n_rows Maximum number rows read. encoding Either \"utf8\" \"utf8-lossy\". Lossy means invalid UTF8 values replaced \"?\" characters. low_memory Reduce memory usage (yield lower performance). rechunk Reallocate contiguous memory chunks / files parsed. skip_rows_after_header Parse first row headers, skip number rows. row_index_name NULL, insert row index column given name DataFrame. row_index_offset Offset start row index column (used name set). try_parse_dates Try automatically parse dates. ISO8601-like formats can inferred, well handful others. succeed, column remains data type pl$String. eol_char Single byte end line character (default: \\n). encountering file Windows line endings (\\r\\n), one can go default \\n. extra \\r removed processed. raise_if_empty FALSE, parsing empty file returns empty DataFrame LazyFrame. truncate_ragged_lines Truncate lines longer schema. reuse_downloaded TRUE(default) URL provided, cache downloaded files session easy reuse.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_ipc.html","id":null,"dir":"Reference","previous_headings":"","what":"Import data from IPC file(s) — from_ipc","title":"Import data from IPC file(s) — from_ipc","text":"read_ipc_polars() imports data Polars DataFrame. scan_ipc_polars() imports data Polars LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_ipc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import data from IPC file(s) — from_ipc","text":"","code":"read_ipc_polars( source, ..., n_rows = NULL, memory_map = TRUE, row_index_name = NULL, row_index_offset = 0L, rechunk = FALSE, cache = TRUE, include_file_paths = NULL ) scan_ipc_polars( source, ..., n_rows = NULL, memory_map = TRUE, row_index_name = NULL, row_index_offset = 0L, rechunk = FALSE, cache = TRUE, include_file_paths = NULL )"},{"path":"https://tidypolars.etiennebacher.com/reference/from_ipc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import data from IPC file(s) — from_ipc","text":"source Path file. can use globbing * scan/read multiple files directory (see examples). ... Ignored. n_rows Maximum number rows read. memory_map logical. TRUE, try memory map file. can greatly improve performance repeated queries OS may cache pages. uncompressed Arrow IPC files can memory mapped. row_index_name NULL, insert row index column given name DataFrame. row_index_offset Offset start row index column (used name set). rechunk case reading multiple files via glob pattern, rechunk final DataFrame contiguous memory chunks. cache Cache result reading. include_file_paths Character value indicating column name include path source file(s).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_ipc.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Import data from IPC file(s) — from_ipc","text":"Hive-style partitioning supported yet.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_ndjson.html","id":null,"dir":"Reference","previous_headings":"","what":"Import data from NDJSON file(s) — from_ndjson","title":"Import data from NDJSON file(s) — from_ndjson","text":"read_ndjson_polars() imports data Polars DataFrame. scan_ndjson_polars() imports data Polars LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_ndjson.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import data from NDJSON file(s) — from_ndjson","text":"","code":"read_ndjson_polars( source, ..., infer_schema_length = 100, batch_size = NULL, n_rows = NULL, low_memory = FALSE, rechunk = FALSE, row_index_name = NULL, row_index_offset = 0, reuse_downloaded = TRUE, ignore_errors = FALSE ) scan_ndjson_polars( source, ..., infer_schema_length = 100, batch_size = NULL, n_rows = NULL, low_memory = FALSE, rechunk = FALSE, row_index_name = NULL, row_index_offset = 0, reuse_downloaded = TRUE, ignore_errors = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/from_ndjson.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import data from NDJSON file(s) — from_ndjson","text":"source Path file URL. possible provide multiple paths provided NDJSON files schema. possible provide several URLs. ... Ignored. infer_schema_length Maximum number rows read infer column types. set 0, columns read UTF-8. NULL, full table scan done (slow). batch_size Number rows processed per thread. n_rows Maximum number rows read. low_memory Reduce memory usage (yield lower performance). rechunk Reallocate contiguous memory chunks / files parsed. row_index_name NULL, insert row index column given name DataFrame. row_index_offset Offset start row index column (used name set). reuse_downloaded TRUE(default) URL provided, cache downloaded files session easy reuse. ignore_errors Keep reading file even lines yield errors. can also use infer_schema_length = 0 read columns UTF8 check values might cause issue.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":null,"dir":"Reference","previous_headings":"","what":"Import data from Parquet file(s) — from_parquet","title":"Import data from Parquet file(s) — from_parquet","text":"read_parquet_polars() imports data Polars DataFrame. scan_parquet_polars() imports data Polars LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import data from Parquet file(s) — from_parquet","text":"","code":"read_parquet_polars( source, ..., n_rows = NULL, row_index_name = NULL, row_index_offset = 0L, parallel = \"auto\", hive_partitioning = NULL, hive_schema = NULL, try_parse_hive_dates = TRUE, glob = TRUE, rechunk = TRUE, low_memory = FALSE, storage_options = NULL, use_statistics = TRUE, cache = TRUE, include_file_paths = NULL ) scan_parquet_polars( source, ..., n_rows = NULL, row_index_name = NULL, row_index_offset = 0L, parallel = \"auto\", hive_partitioning = NULL, hive_schema = NULL, try_parse_hive_dates = TRUE, glob = TRUE, rechunk = FALSE, low_memory = FALSE, storage_options = NULL, use_statistics = TRUE, cache = TRUE, include_file_paths = NULL )"},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import data from Parquet file(s) — from_parquet","text":"source Path file. can use globbing * scan/read multiple files directory (see examples). ... Ignored. n_rows Maximum number rows read. row_index_name NULL, insert row index column given name DataFrame. row_index_offset Offset start row index column (used name set). parallel determines direction parallelism. \"auto\" try determine optimal direction. Can \"auto\", \"columns\", \"row_groups\", \"prefiltered\", \"none\". See 'Details'. hive_partitioning Infer statistics schema Hive partitioned URL use prune reads. NULL (default), automatically enabled single directory passed, otherwise disabled. hive_schema list containing column names data types columns data partitioned, e.g. list(= pl$String, b = pl$Float32). NULL (default), schema Hive partitions inferred. try_parse_hive_dates Whether try parsing hive values date/datetime types. glob Expand path given via globbing rules. rechunk case reading multiple files via glob pattern, rechunk final DataFrame contiguous memory chunks. low_memory Reduce memory usage (yield lower performance). storage_options Experimental. List options necessary scan parquet files different cloud storage providers (GCP, AWS, Azure, HuggingFace). See 'Details' section. use_statistics Use statistics parquet file determine pages can skipped reading. cache Cache result reading. include_file_paths Include path source file(s) column name.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":"on-parallel-strategies","dir":"Reference","previous_headings":"","what":"On parallel strategies","title":"Import data from Parquet file(s) — from_parquet","text":"prefiltered strategy first evaluates pushed-predicates parallel determines mask rows read. , parallelizes columns row groups filtering rows need read. can provide significant speedups large files (.e. many row-groups) predicate filters clustered rows filters heavily. cases, prefiltered may slow scan compared strategies. prefiltered settings falls back auto predicate given.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":"connecting-to-cloud-providers","dir":"Reference","previous_headings":"","what":"Connecting to cloud providers","title":"Import data from Parquet file(s) — from_parquet","text":"Polars supports scanning parquet files different cloud providers. cloud providers currently supported AWS, GCP, Azure. supported keys pass storage_options argument can found : aws gcp azure Currently impossible scan public parquet files GCP without valid service account. sure always include service account storage_options argument.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":"scanning-from-huggingface","dir":"Reference","previous_headings":"","what":"Scanning from HuggingFace","title":"Import data from Parquet file(s) — from_parquet","text":"possible scan data stored HuggingFace using path starting hf://. hf:// path format defined hf://BUCKET/REPOSITORY@REVISION/PATH, : BUCKET one datasets spaces REPOSITORY location repository. usually format username/repo_name. branch can also optionally specified appending @branch. REVISION name branch (commit) use. optional defaults main given. PATH file directory path, glob pattern repository root. Hugging Face API key can passed access private locations using either following methods: Passing token storage_options scan function, e.g. scan_parquet(..., storage_options = list(token = )) Setting HF_TOKEN environment variable, e.g. Sys.setenv(HF_TOKEN = ).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_by.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Group by one or more variables — group_by.RPolarsDataFrame","title":"Group by one or more variables — group_by.RPolarsDataFrame","text":"data operations done groups defined variables. group_by() takes existing Polars Data/LazyFrame converts grouped one operations performed \"group\". ungroup() removes grouping.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_by.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Group by one or more variables — group_by.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' group_by(.data, ..., maintain_order = FALSE, .add = FALSE) # S3 method for class 'RPolarsDataFrame' ungroup(x, ...) # S3 method for class 'RPolarsLazyFrame' group_by(.data, ..., maintain_order = FALSE, .add = FALSE) # S3 method for class 'RPolarsLazyFrame' ungroup(x, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/group_by.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Group by one or more variables — group_by.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Variables group (used group_by() ). used ungroup(). maintain_order Maintain row order. performance reasons, FALSE default). Setting TRUE can slow process large datasets prevents use streaming. .add FALSE (default), group_by() override existing groups. add existing groups, use .add = TRUE. x Polars Data/LazyFrame","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_by.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Group by one or more variables — group_by.RPolarsDataFrame","text":"","code":"by_cyl <- mtcars |> as_polars_df() |> group_by(cyl) by_cyl #> shape: (32, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘ #> Groups [3]: cyl #> Maintain order: FALSE by_cyl |> summarise( disp = mean(disp), hp = mean(hp) ) #> shape: (3, 3) #> ┌─────┬────────────┬────────────┐ #> │ cyl ┆ disp ┆ hp │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪════════════╪════════════╡ #> │ 4.0 ┆ 105.136364 ┆ 82.636364 │ #> │ 6.0 ┆ 183.314286 ┆ 122.285714 │ #> │ 8.0 ┆ 353.1 ┆ 209.214286 │ #> └─────┴────────────┴────────────┘ by_cyl |> filter(disp == max(disp)) #> shape: (3, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 24.4 ┆ 4.0 ┆ 146.7 ┆ 62.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ 10.4 ┆ 8.0 ┆ 472.0 ┆ 205.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 4.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘ #> Groups [3]: cyl #> Maintain order: FALSE"},{"path":"https://tidypolars.etiennebacher.com/reference/group_split.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Grouping metadata — group_split.RPolarsDataFrame","title":"Grouping metadata — group_split.RPolarsDataFrame","text":"group_vars() returns character vector names grouping variables. group_keys() returns data frame one row per group.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_split.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Grouping metadata — group_split.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' group_split(.tbl, ..., .keep = TRUE)"},{"path":"https://tidypolars.etiennebacher.com/reference/group_split.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Grouping metadata — group_split.RPolarsDataFrame","text":".tbl Polars Data/LazyFrame ... .tbl grouped, variables group . .tbl already grouped, ignored. .keep grouping columns kept?","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_split.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Grouping metadata — group_split.RPolarsDataFrame","text":"","code":"pl_g <- polars::as_polars_df(iris) |> group_by(Species) group_split(pl_g) #> [[1]] #> shape: (50, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬─────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4.8 ┆ 3.0 ┆ 1.4 ┆ 0.3 ┆ setosa │ #> │ 5.1 ┆ 3.8 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.2 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 5.3 ┆ 3.7 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.3 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴─────────┘ #> #> [[2]] #> shape: (50, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪════════════╡ #> │ 7.0 ┆ 3.2 ┆ 4.7 ┆ 1.4 ┆ versicolor │ #> │ 6.4 ┆ 3.2 ┆ 4.5 ┆ 1.5 ┆ versicolor │ #> │ 6.9 ┆ 3.1 ┆ 4.9 ┆ 1.5 ┆ versicolor │ #> │ 5.5 ┆ 2.3 ┆ 4.0 ┆ 1.3 ┆ versicolor │ #> │ 6.5 ┆ 2.8 ┆ 4.6 ┆ 1.5 ┆ versicolor │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 5.7 ┆ 3.0 ┆ 4.2 ┆ 1.2 ┆ versicolor │ #> │ 5.7 ┆ 2.9 ┆ 4.2 ┆ 1.3 ┆ versicolor │ #> │ 6.2 ┆ 2.9 ┆ 4.3 ┆ 1.3 ┆ versicolor │ #> │ 5.1 ┆ 2.5 ┆ 3.0 ┆ 1.1 ┆ versicolor │ #> │ 5.7 ┆ 2.8 ┆ 4.1 ┆ 1.3 ┆ versicolor │ #> └──────────────┴─────────────┴──────────────┴─────────────┴────────────┘ #> #> [[3]] #> shape: (50, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 6.3 ┆ 3.3 ┆ 6.0 ┆ 2.5 ┆ virginica │ #> │ 5.8 ┆ 2.7 ┆ 5.1 ┆ 1.9 ┆ virginica │ #> │ 7.1 ┆ 3.0 ┆ 5.9 ┆ 2.1 ┆ virginica │ #> │ 6.3 ┆ 2.9 ┆ 5.6 ┆ 1.8 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.8 ┆ 2.2 ┆ virginica │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ #>"},{"path":"https://tidypolars.etiennebacher.com/reference/group_vars.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Grouping metadata — group_vars.RPolarsDataFrame","title":"Grouping metadata — group_vars.RPolarsDataFrame","text":"group_vars() returns character vector names grouping variables. group_keys() returns data frame one row per group.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_vars.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Grouping metadata — group_vars.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' group_vars(x) # S3 method for class 'RPolarsLazyFrame' group_vars(x) # S3 method for class 'RPolarsDataFrame' group_keys(.tbl, ...) # S3 method for class 'RPolarsLazyFrame' group_keys(.tbl, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/group_vars.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Grouping metadata — group_vars.RPolarsDataFrame","text":"x, .tbl Polars Data/LazyFrame ... dots future extensions must empty.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_vars.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Grouping metadata — group_vars.RPolarsDataFrame","text":"","code":"pl_g <- polars::as_polars_df(mtcars) |> group_by(cyl, am) group_vars(pl_g) #> [1] \"cyl\" \"am\" group_keys(pl_g) #> cyl am #> 1 4 0 #> 2 4 1 #> 3 6 0 #> 4 6 1 #> 5 8 0 #> 6 8 1"},{"path":"https://tidypolars.etiennebacher.com/reference/make_unique_id.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a column with unique id per row values — make_unique_id","title":"Create a column with unique id per row values — make_unique_id","text":"Create column unique id per row values","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/make_unique_id.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a column with unique id per row values — make_unique_id","text":"","code":"make_unique_id(.data, ..., new_col = \"hash\")"},{"path":"https://tidypolars.etiennebacher.com/reference/make_unique_id.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a column with unique id per row values — make_unique_id","text":".data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. new_col Name new column","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/make_unique_id.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a column with unique id per row values — make_unique_id","text":"","code":"mtcars |> as_polars_df() |> make_unique_id(am, gear) #> shape: (32, 12) #> ┌──────┬─────┬───────┬───────┬───┬─────┬──────┬──────┬──────────────────────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ am ┆ gear ┆ carb ┆ hash │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ u64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪══════╪══════╪══════════════════════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 6713333141368562554 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 6713333141368562554 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 1.0 ┆ 6713333141368562554 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 1.0 ┆ 16798766010850734252 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 2.0 ┆ 16798766010850734252 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 2.0 ┆ 6990942474477480077 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 4.0 ┆ 6990942474477480077 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 6.0 ┆ 6990942474477480077 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 8.0 ┆ 6990942474477480077 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 2.0 ┆ 6713333141368562554 │ #> └──────┴─────┴───────┴───────┴───┴─────┴──────┴──────┴──────────────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/mutate.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Create, modify, and delete columns — mutate.RPolarsDataFrame","title":"Create, modify, and delete columns — mutate.RPolarsDataFrame","text":"creates new columns functions existing variables. can also modify (name existing column) delete columns (setting value NULL).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutate.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create, modify, and delete columns — mutate.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' mutate(.data, ..., .by = NULL, .keep = c(\"all\", \"used\", \"unused\", \"none\")) # S3 method for class 'RPolarsLazyFrame' mutate(.data, ..., .by = NULL, .keep = c(\"all\", \"used\", \"unused\", \"none\"))"},{"path":"https://tidypolars.etiennebacher.com/reference/mutate.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create, modify, and delete columns — mutate.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Name-value pairs. name gives name column output. value can : vector length current group (whole data frame ungrouped). NULL, remove column. across() mostly supported, except cases. particular, .cols argument (...), select variables created across(). select helpers supported. See examples. .Optionally, selection columns group just operation, functioning alternative group_by(). group order maintained, use group_by() want control . .keep Control columns .data retained output. Grouping columns columns created ... always kept. \"\" retains columns .data. default. \"used\" retains columns used ... create new columns. useful checking work, displays inputs outputs side-- side. \"unused\" retains columns used ... create new columns. useful generate new columns, longer need columns used generate . \"none\" retain extra columns .data. grouping variables columns created ... kept.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutate.RPolarsDataFrame.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create, modify, and delete columns — mutate.RPolarsDataFrame","text":"lot functions available base R (cos, mean, multiplying, etc.) packages (dplyr::lag(), etc.) implemented efficient way Polars. functions automatically translated Polars syntax hood can continue using classic R syntax functions. Polars built-replacement exist (example custom functions), tidypolars throw error. See vignette Polars expressions know write custom functions accepted tidypolars.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutate.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create, modify, and delete columns — mutate.RPolarsDataFrame","text":"","code":"pl_iris <- polars::as_polars_df(iris) # classic operation mutate(pl_iris, x = Sepal.Width + Sepal.Length) #> shape: (150, 6) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬─────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ x │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪═════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 8.6 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 7.9 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ 7.9 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ 7.7 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 8.6 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ 9.7 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ 8.8 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ 9.5 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ 9.6 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ 8.9 │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴─────┘ # logical operation mutate(pl_iris, x = Sepal.Width > Sepal.Length & Petal.Width > Petal.Length) #> shape: (150, 6) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬───────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ x │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ bool │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪═══════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ false │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ false │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ false │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ false │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ false │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ false │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ false │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ false │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ false │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ false │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴───────┘ # overwrite existing variable mutate(pl_iris, Sepal.Width = Sepal.Width * 2) #> shape: (150, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.1 ┆ 7.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 6.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 6.4 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 6.2 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 7.2 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 6.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 5.0 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 6.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 6.8 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 6.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ # grouped computation pl_iris |> group_by(Species) |> mutate(foo = mean(Sepal.Length)) #> shape: (150, 6) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬───────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ foo │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪═══════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ 6.588 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ 6.588 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ 6.588 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ 6.588 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ 6.588 │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴───────┘ #> Groups [3]: Species #> Maintain order: FALSE # an alternative syntax for grouping is to use `.by` pl_iris |> mutate(foo = mean(Sepal.Length), .by = Species) #> shape: (150, 6) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬───────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ foo │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪═══════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ 6.588 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ 6.588 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ 6.588 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ 6.588 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ 6.588 │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴───────┘ # across() is available pl_iris |> mutate( across(.cols = contains(\"Sepal\"), .fns = mean, .names = \"{.fn}_of_{.col}\") ) #> shape: (150, 7) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬──────────────┬─────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ mean_of_Sepa ┆ mean_of_Sep │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ l.Length ┆ al.Width │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ --- ┆ --- │ #> │ ┆ ┆ ┆ ┆ ┆ f64 ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪══════════════╪═════════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.843333 ┆ 3.057333 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.843333 ┆ 3.057333 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ 5.843333 ┆ 3.057333 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ 5.843333 ┆ 3.057333 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.843333 ┆ 3.057333 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ 5.843333 ┆ 3.057333 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ 5.843333 ┆ 3.057333 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ 5.843333 ┆ 3.057333 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ 5.843333 ┆ 3.057333 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ 5.843333 ┆ 3.057333 │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴──────────────┴─────────────┘ # # It can receive several types of functions: pl_iris |> mutate( across( .cols = contains(\"Sepal\"), .fns = list(mean = mean, sd = ~ sd(.x)), .names = \"{.fn}_of_{.col}\" ) ) #> shape: (150, 9) #> ┌───────────┬───────────┬───────────┬───────────┬───┬───────────┬───────────┬───────────┬──────────┐ #> │ Sepal.Len ┆ Sepal.Wid ┆ Petal.Len ┆ Petal.Wid ┆ … ┆ mean_of_S ┆ sd_of_Sep ┆ mean_of_S ┆ sd_of_Se │ #> │ gth ┆ th ┆ gth ┆ th ┆ ┆ epal.Leng ┆ al.Length ┆ epal.Widt ┆ pal.Widt │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ th ┆ --- ┆ h ┆ h │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ --- ┆ f64 ┆ --- ┆ --- │ #> │ ┆ ┆ ┆ ┆ ┆ f64 ┆ ┆ f64 ┆ f64 │ #> ╞═══════════╪═══════════╪═══════════╪═══════════╪═══╪═══════════╪═══════════╪═══════════╪══════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> └───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴───────────┴──────────┘ # Be careful when using across(.cols = where(...), ...) as it will not include # variables created in the same `...` (this is only the case for `where()`): if (FALSE) { # \\dontrun{ pl_iris |> mutate( foo = 1, across( .cols = where(is.numeric), \\(x) x - 1000 # <<<<<<<<< this will not be applied on variable \"foo\" ) ) } # } # Warning message: # In `across()`, the argument `.cols = where(is.numeric)` will not take into account # variables created in the same `mutate()`/`summarize` call. # Embracing an external variable works some_value <- 1 mutate(pl_iris, x = {{ some_value }}) #> shape: (150, 6) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬─────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ x │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪═════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 1.0 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 1.0 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ 1.0 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ 1.0 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 1.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ 1.0 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ 1.0 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ 1.0 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ 1.0 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ 1.0 │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴─────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/mutating-joins.html","id":null,"dir":"Reference","previous_headings":"","what":"Mutating joins — left_join.RPolarsDataFrame","title":"Mutating joins — left_join.RPolarsDataFrame","text":"Mutating joins add columns y x, matching observations based keys.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutating-joins.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mutating joins — left_join.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' left_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsDataFrame' right_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsDataFrame' full_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsDataFrame' inner_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsLazyFrame' left_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsLazyFrame' right_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsLazyFrame' full_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsLazyFrame' inner_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL )"},{"path":"https://tidypolars.etiennebacher.com/reference/mutating-joins.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mutating joins — left_join.RPolarsDataFrame","text":"x, y Two Polars Data/LazyFrames Variables join . NULL (default), *_join() perform natural join, using variables common across x y. message lists variables can check correct; suppress message supplying explicitly. can take character vector, like c(\"x\", \"y\") x y datasets. join variables name, use equalities character vector, like c(\"x1\" = \"x2\", \"y\"). use character vector, join can done using strict equality. can also specification created dplyr::join_by(). Contrary input character vector shown , join_by() uses unquoted column names, e.g join_by(x1 == x2, y). Finally, inner_join() also supports inequality joins, e.g. join_by(x1 >= x2), helpers (), overlaps(), within(). See documentation dplyr::join_by() information. join types likely support inequality joins future. copy, keep supported. suffix non-joined duplicate variables x y, suffixes added output disambiguate . character vector length 2. ... Dots empty. na_matches two NA values match? \"na\", default, treats two NA values equal. \"never\" treats two NA values different never match together values. Note joining Polars Data/LazyFrames, NaN always considered equal, matter value na_matches. differs original dplyr implementation. relationship Handling expected relationship keys x y. Must one following: NULL, default, equivalent \"many--many\". expect relationship x y. \"one--one\" expects row x match 1 row y row y match 1 row x. \"one--many\" expects row y match 1 row x. \"many--one\" expects row x matches 1 row y.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutating-joins.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Mutating joins — left_join.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutating-joins.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mutating joins — left_join.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame( x = c(1, 2, 3), y1 = c(1, 2, 3), z = c(1, 2, 3) ) test2 <- polars::pl$DataFrame( x = c(1, 2, 4), y2 = c(1, 2, 4), z2 = c(4, 5, 7) ) test #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y1 ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 │ #> └─────┴─────┴─────┘ test2 #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y2 ┆ z2 │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 1.0 ┆ 1.0 ┆ 4.0 │ #> │ 2.0 ┆ 2.0 ┆ 5.0 │ #> │ 4.0 ┆ 4.0 ┆ 7.0 │ #> └─────┴─────┴─────┘ # default is to use common columns, here \"x\" only left_join(test, test2) #> Joining by `x` #> shape: (3, 5) #> ┌─────┬─────┬─────┬──────┬──────┐ #> │ x ┆ y1 ┆ z ┆ y2 ┆ z2 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╪══════╪══════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 4.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 ┆ 2.0 ┆ 5.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 ┆ null ┆ null │ #> └─────┴─────┴─────┴──────┴──────┘ # we can specify the columns on which to join with join_by()... left_join(test, test2, by = join_by(x, y1 == y2)) #> shape: (3, 4) #> ┌─────┬─────┬─────┬──────┐ #> │ x ┆ y1 ┆ z ┆ z2 │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╪══════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 ┆ 4.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 ┆ 5.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 ┆ null │ #> └─────┴─────┴─────┴──────┘ # ... or with a character vector left_join(test, test2, by = c(\"x\", \"y1\" = \"y2\")) #> shape: (3, 4) #> ┌─────┬─────┬─────┬──────┐ #> │ x ┆ y1 ┆ z ┆ z2 │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╪══════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 ┆ 4.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 ┆ 5.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 ┆ null │ #> └─────┴─────┴─────┴──────┘ # we can customize the suffix of common column names not used to join test2 <- polars::pl$DataFrame( x = c(1, 2, 4), y1 = c(1, 2, 4), z = c(4, 5, 7) ) left_join(test, test2, by = \"x\", suffix = c(\"_left\", \"_right\")) #> shape: (3, 5) #> ┌─────┬─────────┬────────┬──────────┬─────────┐ #> │ x ┆ y1_left ┆ z_left ┆ y1_right ┆ z_right │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════════╪════════╪══════════╪═════════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 4.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 ┆ 2.0 ┆ 5.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 ┆ null ┆ null │ #> └─────┴─────────┴────────┴──────────┴─────────┘ # the argument \"relationship\" ensures the join matches the expectation country <- polars::pl$DataFrame( iso = c(\"FRA\", \"DEU\"), value = 1:2 ) country #> shape: (2, 2) #> ┌─────┬───────┐ #> │ iso ┆ value │ #> │ --- ┆ --- │ #> │ str ┆ i32 │ #> ╞═════╪═══════╡ #> │ FRA ┆ 1 │ #> │ DEU ┆ 2 │ #> └─────┴───────┘ country_year <- polars::pl$DataFrame( iso = rep(c(\"FRA\", \"DEU\"), each = 2), year = rep(2019:2020, 2), value2 = 3:6 ) country_year #> shape: (4, 3) #> ┌─────┬──────┬────────┐ #> │ iso ┆ year ┆ value2 │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ i32 │ #> ╞═════╪══════╪════════╡ #> │ FRA ┆ 2019 ┆ 3 │ #> │ FRA ┆ 2020 ┆ 4 │ #> │ DEU ┆ 2019 ┆ 5 │ #> │ DEU ┆ 2020 ┆ 6 │ #> └─────┴──────┴────────┘ # We expect that each row in \"x\" matches only one row in \"y\" but, it's not # true as each row of \"x\" matches two rows of \"y\" tryCatch( left_join(country, country_year, join_by(iso), relationship = \"one-to-one\"), error = function(e) e ) #> 0: In R: in $collect(): #> 0: During function call [pkgdown::build_site_github_pages(new_process = FALSE, install = TRUE)] #> 1: Encountered the following error in Rust-Polars: #> \tjoin keys did not fulfill 1:1 validation #> > # A correct expectation would be \"one-to-many\": left_join(country, country_year, join_by(iso), relationship = \"one-to-many\") #> shape: (4, 4) #> ┌─────┬───────┬──────┬────────┐ #> │ iso ┆ value ┆ year ┆ value2 │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ i32 ┆ i32 │ #> ╞═════╪═══════╪══════╪════════╡ #> │ FRA ┆ 1 ┆ 2019 ┆ 3 │ #> │ FRA ┆ 1 ┆ 2020 ┆ 4 │ #> │ DEU ┆ 2 ┆ 2019 ┆ 5 │ #> │ DEU ┆ 2 ┆ 2020 ┆ 6 │ #> └─────┴───────┴──────┴────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_longer.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","title":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","text":"Pivot Data/LazyFrame wide long","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_longer.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' pivot_longer( data, cols, ..., names_to = \"name\", names_prefix = NULL, values_to = \"value\" ) # S3 method for class 'RPolarsLazyFrame' pivot_longer( data, cols, ..., names_to = \"name\", names_prefix = NULL, values_to = \"value\" )"},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_longer.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","text":"data Polars Data/LazyFrame cols Columns pivot longer format. Can anything accepted dplyr::select(). ... Dots empty. names_to (quoted) name column contain column names specified cols. names_prefix regular expression used remove matching text start variable name. values_to string specifying name column create data stored cell values.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_longer.RPolarsDataFrame.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_longer.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","text":"","code":"pl_relig_income <- polars::pl$DataFrame(tidyr::relig_income) #> Warning: Passing a `data.frame` or `RPolarsDataFrame` to `pl$DataFrame()` is deprecated and will be removed in the future. Use `as_polars_df()` instead. pl_relig_income #> shape: (18, 11) #> ┌────────────────────┬───────┬─────────┬─────────┬───┬──────────┬───────────┬───────┬──────────────┐ #> │ religion ┆ <$10k ┆ $10-20k ┆ $20-30k ┆ … ┆ $75-100k ┆ $100-150k ┆ >150k ┆ Don't │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ know/refused │ #> │ str ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ --- │ #> │ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ f64 │ #> ╞════════════════════╪═══════╪═════════╪═════════╪═══╪══════════╪═══════════╪═══════╪══════════════╡ #> │ Agnostic ┆ 27.0 ┆ 34.0 ┆ 60.0 ┆ … ┆ 122.0 ┆ 109.0 ┆ 84.0 ┆ 96.0 │ #> │ Atheist ┆ 12.0 ┆ 27.0 ┆ 37.0 ┆ … ┆ 73.0 ┆ 59.0 ┆ 74.0 ┆ 76.0 │ #> │ Buddhist ┆ 27.0 ┆ 21.0 ┆ 30.0 ┆ … ┆ 62.0 ┆ 39.0 ┆ 53.0 ┆ 54.0 │ #> │ Catholic ┆ 418.0 ┆ 617.0 ┆ 732.0 ┆ … ┆ 949.0 ┆ 792.0 ┆ 633.0 ┆ 1489.0 │ #> │ Don’t know/refused ┆ 15.0 ┆ 14.0 ┆ 15.0 ┆ … ┆ 21.0 ┆ 17.0 ┆ 18.0 ┆ 116.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ Orthodox ┆ 13.0 ┆ 17.0 ┆ 23.0 ┆ … ┆ 38.0 ┆ 42.0 ┆ 46.0 ┆ 73.0 │ #> │ Other Christian ┆ 9.0 ┆ 7.0 ┆ 11.0 ┆ … ┆ 18.0 ┆ 14.0 ┆ 12.0 ┆ 18.0 │ #> │ Other Faiths ┆ 20.0 ┆ 33.0 ┆ 40.0 ┆ … ┆ 46.0 ┆ 40.0 ┆ 41.0 ┆ 71.0 │ #> │ Other World ┆ 5.0 ┆ 2.0 ┆ 3.0 ┆ … ┆ 3.0 ┆ 4.0 ┆ 4.0 ┆ 8.0 │ #> │ Religions ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │ #> │ Unaffiliated ┆ 217.0 ┆ 299.0 ┆ 374.0 ┆ … ┆ 407.0 ┆ 321.0 ┆ 258.0 ┆ 597.0 │ #> └────────────────────┴───────┴─────────┴─────────┴───┴──────────┴───────────┴───────┴──────────────┘ pl_relig_income |> pivot_longer(!religion, names_to = \"income\", values_to = \"count\") #> shape: (180, 3) #> ┌──────────────┬────────────────────┬───────┐ #> │ religion ┆ income ┆ count │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ f64 │ #> ╞══════════════╪════════════════════╪═══════╡ #> │ Agnostic ┆ <$10k ┆ 27.0 │ #> │ Agnostic ┆ $10-20k ┆ 34.0 │ #> │ Agnostic ┆ $20-30k ┆ 60.0 │ #> │ Agnostic ┆ $30-40k ┆ 81.0 │ #> │ Agnostic ┆ $40-50k ┆ 76.0 │ #> │ … ┆ … ┆ … │ #> │ Unaffiliated ┆ $50-75k ┆ 528.0 │ #> │ Unaffiliated ┆ $75-100k ┆ 407.0 │ #> │ Unaffiliated ┆ $100-150k ┆ 321.0 │ #> │ Unaffiliated ┆ >150k ┆ 258.0 │ #> │ Unaffiliated ┆ Don't know/refused ┆ 597.0 │ #> └──────────────┴────────────────────┴───────┘ pl_billboard <- polars::pl$DataFrame(tidyr::billboard) #> Warning: Passing a `data.frame` or `RPolarsDataFrame` to `pl$DataFrame()` is deprecated and will be removed in the future. Use `as_polars_df()` instead. pl_billboard #> shape: (317, 79) #> ┌──────────────────┬─────────────────────────┬──────────────┬──────┬───┬──────┬──────┬──────┬──────┐ #> │ artist ┆ track ┆ date.entered ┆ wk1 ┆ … ┆ wk73 ┆ wk74 ┆ wk75 ┆ wk76 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ date ┆ f64 ┆ ┆ bool ┆ bool ┆ bool ┆ bool │ #> ╞══════════════════╪═════════════════════════╪══════════════╪══════╪═══╪══════╪══════╪══════╪══════╡ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 87.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 2Ge+her ┆ The Hardest Part Of ... ┆ 2000-09-02 ┆ 91.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 3 Doors Down ┆ Kryptonite ┆ 2000-04-08 ┆ 81.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 3 Doors Down ┆ Loser ┆ 2000-10-21 ┆ 76.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 504 Boyz ┆ Wobble Wobble ┆ 2000-04-15 ┆ 57.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ Yankee Grey ┆ Another Nine Minutes ┆ 2000-04-29 ┆ 86.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ Yearwood, Trisha ┆ Real Live Woman ┆ 2000-04-01 ┆ 85.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ Ying Yang Twins ┆ Whistle While You Tw... ┆ 2000-03-18 ┆ 95.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ Zombie Nation ┆ Kernkraft 400 ┆ 2000-09-02 ┆ 99.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 60.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> └──────────────────┴─────────────────────────┴──────────────┴──────┴───┴──────┴──────┴──────┴──────┘ pl_billboard |> pivot_longer( cols = starts_with(\"wk\"), names_to = \"week\", names_prefix = \"wk\", values_to = \"rank\", ) #> shape: (24_092, 5) #> ┌─────────────────┬─────────────────────────┬──────────────┬──────┬──────┐ #> │ artist ┆ track ┆ date.entered ┆ week ┆ rank │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ date ┆ str ┆ f64 │ #> ╞═════════════════╪═════════════════════════╪══════════════╪══════╪══════╡ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 2 ┆ 82.0 │ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 76 ┆ null │ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 75 ┆ null │ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 74 ┆ null │ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 73 ┆ null │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 32 ┆ 28.0 │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 56 ┆ null │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 17 ┆ 2.0 │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 3 ┆ 29.0 │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 76 ┆ null │ #> └─────────────────┴─────────────────────────┴──────────────┴──────┴──────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_wider.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","title":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","text":"Pivot DataFrame long wide","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_wider.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' pivot_wider( data, ..., id_cols = NULL, names_from = name, values_from = value, names_prefix = \"\", names_sep = \"_\", names_glue = NULL, values_fill = NULL )"},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_wider.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","text":"data Polars DataFrame (LazyFrames supported). ... Dots empty. id_cols set columns uniquely identify observation. Typically used redundant variables, .e. variables whose values perfectly correlated existing variables. Defaults columns data except columns specified names_from values_from. tidyselect expression supplied, evaluated data removing columns specified names_from values_from. names_from (quoted unquoted) column names whose values used names new columns. values_from (quoted unquoted) column names whose values used fill new columns. names_prefix String added start every variable name. particularly useful names_from numeric vector want create syntactic variable names. names_sep names_from values_from contains multiple variables, used join values together single string use column name. names_glue Instead names_sep names_prefix, can supply glue specification uses names_from columns create custom column names. values_fill scalar used replace missing values new columns. Note type value applied new columns. example, provide character value fill numeric columns, columns converted character.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_wider.RPolarsDataFrame.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_wider.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","text":"","code":"pl_fish_encounters <- polars::pl$DataFrame(tidyr::fish_encounters) #> Warning: Passing a `data.frame` or `RPolarsDataFrame` to `pl$DataFrame()` is deprecated and will be removed in the future. Use `as_polars_df()` instead. pl_fish_encounters |> pivot_wider(names_from = station, values_from = seen) #> shape: (19, 12) #> ┌──────┬─────────┬───────┬────────┬───┬──────┬──────┬──────┬──────┐ #> │ fish ┆ Release ┆ I80_1 ┆ Lisbon ┆ … ┆ BCE2 ┆ BCW2 ┆ MAE ┆ MAW │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ cat ┆ i32 ┆ i32 ┆ i32 ┆ ┆ i32 ┆ i32 ┆ i32 ┆ i32 │ #> ╞══════╪═════════╪═══════╪════════╪═══╪══════╪══════╪══════╪══════╡ #> │ 4842 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4843 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4844 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4845 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 4847 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4861 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4862 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ null ┆ null │ #> │ 4863 ┆ 1 ┆ 1 ┆ null ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 4864 ┆ 1 ┆ 1 ┆ null ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 4865 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> └──────┴─────────┴───────┴────────┴───┴──────┴──────┴──────┴──────┘ pl_fish_encounters |> pivot_wider(names_from = station, values_from = seen, values_fill = 0) #> shape: (19, 12) #> ┌──────┬─────────┬───────┬────────┬───┬──────┬──────┬─────┬─────┐ #> │ fish ┆ Release ┆ I80_1 ┆ Lisbon ┆ … ┆ BCE2 ┆ BCW2 ┆ MAE ┆ MAW │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ cat ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════════╪═══════╪════════╪═══╪══════╪══════╪═════╪═════╡ #> │ 4842 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 4843 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 4844 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 4845 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> │ 4847 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4861 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 4862 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 0.0 ┆ 0.0 │ #> │ 4863 ┆ 1.0 ┆ 1.0 ┆ 0.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> │ 4864 ┆ 1.0 ┆ 1.0 ┆ 0.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> │ 4865 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> └──────┴─────────┴───────┴────────┴───┴──────┴──────┴─────┴─────┘ # be careful about the type of the replacement value! pl_fish_encounters |> pivot_wider(names_from = station, values_from = seen, values_fill = \"a\") #> shape: (19, 12) #> ┌──────┬─────────┬───────┬────────┬───┬──────┬──────┬─────┬─────┐ #> │ fish ┆ Release ┆ I80_1 ┆ Lisbon ┆ … ┆ BCE2 ┆ BCW2 ┆ MAE ┆ MAW │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ cat ┆ str ┆ str ┆ str ┆ ┆ str ┆ str ┆ str ┆ str │ #> ╞══════╪═════════╪═══════╪════════╪═══╪══════╪══════╪═════╪═════╡ #> │ 4842 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4843 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4844 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4845 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ a ┆ a ┆ a ┆ a │ #> │ 4847 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ a ┆ a ┆ a ┆ a │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4861 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4862 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ a ┆ a │ #> │ 4863 ┆ 1 ┆ 1 ┆ a ┆ … ┆ a ┆ a ┆ a ┆ a │ #> │ 4864 ┆ 1 ┆ 1 ┆ a ┆ … ┆ a ┆ a ┆ a ┆ a │ #> │ 4865 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ a ┆ a ┆ a ┆ a │ #> └──────┴─────────┴───────┴────────┴───┴──────┴──────┴─────┴─────┘ # using \"names_glue\" to specify the names of new columns production <- expand.grid( product = c(\"A\", \"B\"), country = c(\"AI\", \"EI\"), year = 2000:2014 ) |> filter((product == \"A\" & country == \"AI\") | product == \"B\") |> mutate(production = 1:45) |> as_polars_df() production #> shape: (45, 4) #> ┌─────────┬─────────┬──────┬────────────┐ #> │ product ┆ country ┆ year ┆ production │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ cat ┆ cat ┆ i32 ┆ i32 │ #> ╞═════════╪═════════╪══════╪════════════╡ #> │ A ┆ AI ┆ 2000 ┆ 1 │ #> │ B ┆ AI ┆ 2000 ┆ 2 │ #> │ B ┆ EI ┆ 2000 ┆ 3 │ #> │ A ┆ AI ┆ 2001 ┆ 4 │ #> │ B ┆ AI ┆ 2001 ┆ 5 │ #> │ … ┆ … ┆ … ┆ … │ #> │ B ┆ AI ┆ 2013 ┆ 41 │ #> │ B ┆ EI ┆ 2013 ┆ 42 │ #> │ A ┆ AI ┆ 2014 ┆ 43 │ #> │ B ┆ AI ┆ 2014 ┆ 44 │ #> │ B ┆ EI ┆ 2014 ┆ 45 │ #> └─────────┴─────────┴──────┴────────────┘ production |> pivot_wider( names_from = c(product, country), values_from = production, names_glue = \"prod_{product}_{country}\" ) #> shape: (15, 4) #> ┌──────┬───────────┬───────────┬───────────┐ #> │ year ┆ prod_A_AI ┆ prod_B_AI ┆ prod_B_EI │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ i32 ┆ i32 ┆ i32 ┆ i32 │ #> ╞══════╪═══════════╪═══════════╪═══════════╡ #> │ 2000 ┆ 1 ┆ 2 ┆ 3 │ #> │ 2001 ┆ 4 ┆ 5 ┆ 6 │ #> │ 2002 ┆ 7 ┆ 8 ┆ 9 │ #> │ 2003 ┆ 10 ┆ 11 ┆ 12 │ #> │ 2004 ┆ 13 ┆ 14 ┆ 15 │ #> │ … ┆ … ┆ … ┆ … │ #> │ 2010 ┆ 31 ┆ 32 ┆ 33 │ #> │ 2011 ┆ 34 ┆ 35 ┆ 36 │ #> │ 2012 ┆ 37 ┆ 38 ┆ 39 │ #> │ 2013 ┆ 40 ┆ 41 ┆ 42 │ #> │ 2014 ┆ 43 ┆ 44 ┆ 45 │ #> └──────┴───────────┴───────────┴───────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/pull.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract a variable of a Data/LazyFrame — pull.RPolarsDataFrame","title":"Extract a variable of a Data/LazyFrame — pull.RPolarsDataFrame","text":"returns R vector Polars Series.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pull.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract a variable of a Data/LazyFrame — pull.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' pull(.data, var, ...) # S3 method for class 'RPolarsLazyFrame' pull(.data, var, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/pull.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract a variable of a Data/LazyFrame — pull.RPolarsDataFrame","text":".data Polars Data/LazyFrame var quoted unquoted variable name, variable index. ... Dots empty.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pull.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract a variable of a Data/LazyFrame — pull.RPolarsDataFrame","text":"","code":"pl_test <- as_polars_df(iris) pull(pl_test, Sepal.Length) #> [1] 5.1 4.9 4.7 4.6 5.0 5.4 4.6 5.0 4.4 4.9 5.4 4.8 4.8 4.3 5.8 5.7 5.4 5.1 #> [19] 5.7 5.1 5.4 5.1 4.6 5.1 4.8 5.0 5.0 5.2 5.2 4.7 4.8 5.4 5.2 5.5 4.9 5.0 #> [37] 5.5 4.9 4.4 5.1 5.0 4.5 4.4 5.0 5.1 4.8 5.1 4.6 5.3 5.0 7.0 6.4 6.9 5.5 #> [55] 6.5 5.7 6.3 4.9 6.6 5.2 5.0 5.9 6.0 6.1 5.6 6.7 5.6 5.8 6.2 5.6 5.9 6.1 #> [73] 6.3 6.1 6.4 6.6 6.8 6.7 6.0 5.7 5.5 5.5 5.8 6.0 5.4 6.0 6.7 6.3 5.6 5.5 #> [91] 5.5 6.1 5.8 5.0 5.6 5.7 5.7 6.2 5.1 5.7 6.3 5.8 7.1 6.3 6.5 7.6 4.9 7.3 #> [109] 6.7 7.2 6.5 6.4 6.8 5.7 5.8 6.4 6.5 7.7 7.7 6.0 6.9 5.6 7.7 6.3 6.7 7.2 #> [127] 6.2 6.1 6.4 7.2 7.4 7.9 6.4 6.3 6.1 7.7 6.3 6.4 6.0 6.9 6.7 6.9 5.8 6.8 #> [145] 6.7 6.7 6.3 6.5 6.2 5.9 pull(pl_test, \"Sepal.Length\") #> [1] 5.1 4.9 4.7 4.6 5.0 5.4 4.6 5.0 4.4 4.9 5.4 4.8 4.8 4.3 5.8 5.7 5.4 5.1 #> [19] 5.7 5.1 5.4 5.1 4.6 5.1 4.8 5.0 5.0 5.2 5.2 4.7 4.8 5.4 5.2 5.5 4.9 5.0 #> [37] 5.5 4.9 4.4 5.1 5.0 4.5 4.4 5.0 5.1 4.8 5.1 4.6 5.3 5.0 7.0 6.4 6.9 5.5 #> [55] 6.5 5.7 6.3 4.9 6.6 5.2 5.0 5.9 6.0 6.1 5.6 6.7 5.6 5.8 6.2 5.6 5.9 6.1 #> [73] 6.3 6.1 6.4 6.6 6.8 6.7 6.0 5.7 5.5 5.5 5.8 6.0 5.4 6.0 6.7 6.3 5.6 5.5 #> [91] 5.5 6.1 5.8 5.0 5.6 5.7 5.7 6.2 5.1 5.7 6.3 5.8 7.1 6.3 6.5 7.6 4.9 7.3 #> [109] 6.7 7.2 6.5 6.4 6.8 5.7 5.8 6.4 6.5 7.7 7.7 6.0 6.9 5.6 7.7 6.3 6.7 7.2 #> [127] 6.2 6.1 6.4 7.2 7.4 7.9 6.4 6.3 6.1 7.7 6.3 6.4 6.0 6.9 6.7 6.9 5.8 6.8 #> [145] 6.7 6.7 6.3 6.5 6.2 5.9"},{"path":"https://tidypolars.etiennebacher.com/reference/reexports.html","id":null,"dir":"Reference","previous_headings":"","what":"Objects exported from other packages — reexports","title":"Objects exported from other packages — reexports","text":"objects imported packages. Follow links see documentation. polars as_polars_df, as_polars_lf","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/relocate.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Change column order — relocate.RPolarsDataFrame","title":"Change column order — relocate.RPolarsDataFrame","text":"Use relocate() change column positions, using syntax select() make easy move blocks columns .","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/relocate.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Change column order — relocate.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' relocate(.data, ..., .before = NULL, .after = NULL) # S3 method for class 'RPolarsLazyFrame' relocate(.data, ..., .before = NULL, .after = NULL)"},{"path":"https://tidypolars.etiennebacher.com/reference/relocate.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Change column order — relocate.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. ., .Column name (either quoted unquoted) indicates destination columns selected .... Supplying neither move columns left-hand side; specifying error.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/relocate.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Change column order — relocate.RPolarsDataFrame","text":"","code":"dat <- as_polars_df(mtcars) dat |> relocate(hp, vs, .before = cyl) #> shape: (32, 11) #> ┌──────┬───────┬─────┬─────┬───┬───────┬─────┬──────┬──────┐ #> │ mpg ┆ hp ┆ vs ┆ cyl ┆ … ┆ qsec ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═══════╪═════╪═════╪═══╪═══════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 110.0 ┆ 0.0 ┆ 6.0 ┆ … ┆ 16.46 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 110.0 ┆ 0.0 ┆ 6.0 ┆ … ┆ 17.02 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 93.0 ┆ 1.0 ┆ 4.0 ┆ … ┆ 18.61 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 110.0 ┆ 1.0 ┆ 6.0 ┆ … ┆ 19.44 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 175.0 ┆ 0.0 ┆ 8.0 ┆ … ┆ 17.02 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 113.0 ┆ 1.0 ┆ 4.0 ┆ … ┆ 16.9 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 264.0 ┆ 0.0 ┆ 8.0 ┆ … ┆ 14.5 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 175.0 ┆ 0.0 ┆ 6.0 ┆ … ┆ 15.5 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 335.0 ┆ 0.0 ┆ 8.0 ┆ … ┆ 14.6 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 109.0 ┆ 1.0 ┆ 4.0 ┆ … ┆ 18.6 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴───────┴─────┴─────┴───┴───────┴─────┴──────┴──────┘ # if .before and .after are not specified, selected columns are moved to the # first positions dat |> relocate(hp, vs) #> shape: (32, 11) #> ┌───────┬─────┬──────┬─────┬───┬───────┬─────┬──────┬──────┐ #> │ hp ┆ vs ┆ mpg ┆ cyl ┆ … ┆ qsec ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═══════╪═════╪══════╪═════╪═══╪═══════╪═════╪══════╪══════╡ #> │ 110.0 ┆ 0.0 ┆ 21.0 ┆ 6.0 ┆ … ┆ 16.46 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 110.0 ┆ 0.0 ┆ 21.0 ┆ 6.0 ┆ … ┆ 17.02 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 93.0 ┆ 1.0 ┆ 22.8 ┆ 4.0 ┆ … ┆ 18.61 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 110.0 ┆ 1.0 ┆ 21.4 ┆ 6.0 ┆ … ┆ 19.44 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 175.0 ┆ 0.0 ┆ 18.7 ┆ 8.0 ┆ … ┆ 17.02 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 113.0 ┆ 1.0 ┆ 30.4 ┆ 4.0 ┆ … ┆ 16.9 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 264.0 ┆ 0.0 ┆ 15.8 ┆ 8.0 ┆ … ┆ 14.5 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 175.0 ┆ 0.0 ┆ 19.7 ┆ 6.0 ┆ … ┆ 15.5 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 335.0 ┆ 0.0 ┆ 15.0 ┆ 8.0 ┆ … ┆ 14.6 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 109.0 ┆ 1.0 ┆ 21.4 ┆ 4.0 ┆ … ┆ 18.6 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └───────┴─────┴──────┴─────┴───┴───────┴─────┴──────┴──────┘ # .before and .after can be quoted or unquoted dat |> relocate(hp, vs, .after = \"gear\") #> shape: (32, 11) #> ┌──────┬─────┬───────┬──────┬───┬──────┬───────┬─────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ drat ┆ … ┆ gear ┆ hp ┆ vs ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪══════╪═══╪══════╪═══════╪═════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 3.9 ┆ … ┆ 4.0 ┆ 110.0 ┆ 0.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 3.9 ┆ … ┆ 4.0 ┆ 110.0 ┆ 0.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 3.85 ┆ … ┆ 4.0 ┆ 93.0 ┆ 1.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 3.08 ┆ … ┆ 3.0 ┆ 110.0 ┆ 1.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 3.15 ┆ … ┆ 3.0 ┆ 175.0 ┆ 0.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 3.77 ┆ … ┆ 5.0 ┆ 113.0 ┆ 1.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 4.22 ┆ … ┆ 5.0 ┆ 264.0 ┆ 0.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 3.62 ┆ … ┆ 5.0 ┆ 175.0 ┆ 0.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 3.54 ┆ … ┆ 5.0 ┆ 335.0 ┆ 0.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 4.11 ┆ … ┆ 4.0 ┆ 109.0 ┆ 1.0 ┆ 2.0 │ #> └──────┴─────┴───────┴──────┴───┴──────┴───────┴─────┴──────┘ # select helpers are also available dat |> relocate(contains(\"[aeiou]\")) #> shape: (32, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘ dat |> relocate(hp, vs, .after = last_col()) #> shape: (32, 11) #> ┌──────┬─────┬───────┬──────┬───┬──────┬──────┬───────┬─────┐ #> │ mpg ┆ cyl ┆ disp ┆ drat ┆ … ┆ gear ┆ carb ┆ hp ┆ vs │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪══════╪═══╪══════╪══════╪═══════╪═════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 3.9 ┆ … ┆ 4.0 ┆ 4.0 ┆ 110.0 ┆ 0.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 3.9 ┆ … ┆ 4.0 ┆ 4.0 ┆ 110.0 ┆ 0.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 3.85 ┆ … ┆ 4.0 ┆ 1.0 ┆ 93.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 3.08 ┆ … ┆ 3.0 ┆ 1.0 ┆ 110.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 3.15 ┆ … ┆ 3.0 ┆ 2.0 ┆ 175.0 ┆ 0.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 3.77 ┆ … ┆ 5.0 ┆ 2.0 ┆ 113.0 ┆ 1.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 4.22 ┆ … ┆ 5.0 ┆ 4.0 ┆ 264.0 ┆ 0.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 3.62 ┆ … ┆ 5.0 ┆ 6.0 ┆ 175.0 ┆ 0.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 3.54 ┆ … ┆ 5.0 ┆ 8.0 ┆ 335.0 ┆ 0.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 4.11 ┆ … ┆ 4.0 ┆ 2.0 ┆ 109.0 ┆ 1.0 │ #> └──────┴─────┴───────┴──────┴───┴──────┴──────┴───────┴─────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/rename.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Rename columns — rename.RPolarsDataFrame","title":"Rename columns — rename.RPolarsDataFrame","text":"Rename columns","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/rename.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rename columns — rename.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' rename(.data, ...) # S3 method for class 'RPolarsLazyFrame' rename(.data, ...) # S3 method for class 'RPolarsDataFrame' rename_with(.data, .fn, .cols = tidyselect::everything(), ...) # S3 method for class 'RPolarsLazyFrame' rename_with(.data, .fn, .cols = tidyselect::everything(), ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/rename.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Rename columns — rename.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... rename(), use new_name = old_name rename selected variables. also possible use quotation marks, e.g \"new_name\" = \"old_name\". rename_with, additional arguments passed fn. .fn Function apply column names .cols Columns apply fn. Can anything accepted dplyr::select().","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/rename.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rename columns — rename.RPolarsDataFrame","text":"","code":"pl_test <- polars::as_polars_df(mtcars) rename(pl_test, miles_per_gallon = mpg, horsepower = \"hp\") #> shape: (32, 11) #> ┌──────────────────┬─────┬───────┬────────────┬───┬─────┬─────┬──────┬──────┐ #> │ miles_per_gallon ┆ cyl ┆ disp ┆ horsepower ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════════════════╪═════╪═══════╪════════════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────────────────┴─────┴───────┴────────────┴───┴─────┴─────┴──────┴──────┘ rename(pl_test, `Miles per gallon` = \"mpg\", `Horse power` = \"hp\") #> shape: (32, 11) #> ┌──────────────────┬─────┬───────┬─────────────┬───┬─────┬─────┬──────┬──────┐ #> │ Miles per gallon ┆ cyl ┆ disp ┆ Horse power ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════════════════╪═════╪═══════╪═════════════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────────────────┴─────┴───────┴─────────────┴───┴─────┴─────┴──────┴──────┘ rename_with(pl_test, toupper, .cols = contains(\"p\")) #> shape: (32, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ MPG ┆ cyl ┆ DISP ┆ HP ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘ pl_test_2 <- polars::as_polars_df(iris) rename_with(pl_test_2, function(x) tolower(gsub(\".\", \"_\", x, fixed = TRUE))) #> shape: (150, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ sepal_length ┆ sepal_width ┆ petal_length ┆ petal_width ┆ species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ rename_with(pl_test_2, \\(x) tolower(gsub(\".\", \"_\", x, fixed = TRUE))) #> shape: (150, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ sepal_length ┆ sepal_width ┆ petal_length ┆ petal_width ┆ species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/replace_na.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Replace NAs with specified values — replace_na.RPolarsDataFrame","title":"Replace NAs with specified values — replace_na.RPolarsDataFrame","text":"Replace NAs specified values","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/replace_na.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Replace NAs with specified values — replace_na.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' replace_na(data, replace, ...) # S3 method for class 'RPolarsLazyFrame' replace_na(data, replace, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/replace_na.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Replace NAs with specified values — replace_na.RPolarsDataFrame","text":"data Polars Data/LazyFrame replace Either scalar used replace NA columns, named list column name value used replace NA . ... Dots empty.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/replace_na.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Replace NAs with specified values — replace_na.RPolarsDataFrame","text":"","code":"pl_test <- polars::pl$DataFrame(x = c(NA, 1), y = c(2, NA)) # replace all NA with 0 replace_na(pl_test, 0) #> shape: (2, 2) #> ┌─────┬─────┐ #> │ x ┆ y │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞═════╪═════╡ #> │ 0.0 ┆ 2.0 │ #> │ 1.0 ┆ 0.0 │ #> └─────┴─────┘ # custom replacement per column replace_na(pl_test, list(x = 0, y = 999)) #> shape: (2, 2) #> ┌─────┬───────┐ #> │ x ┆ y │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞═════╪═══════╡ #> │ 0.0 ┆ 2.0 │ #> │ 1.0 ┆ 999.0 │ #> └─────┴───────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/rowwise.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Group input by rows — rowwise.RPolarsDataFrame","title":"Group input by rows — rowwise.RPolarsDataFrame","text":"[EXPERIMENTAL] rowwise() allows compute Data/LazyFrame row---time. useful vectorised function exist. rowwise() produces another type grouped data, therefore can removed ungroup().","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/rowwise.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Group input by rows — rowwise.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' rowwise(data, ...) # S3 method for class 'RPolarsLazyFrame' rowwise(data, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/rowwise.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Group input by rows — rowwise.RPolarsDataFrame","text":"data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/rowwise.RPolarsDataFrame.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Group input by rows — rowwise.RPolarsDataFrame","text":"Polars Data/LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/rowwise.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Group input by rows — rowwise.RPolarsDataFrame","text":"","code":"df <- polars::pl$DataFrame(x = c(1, 3, 4), y = c(2, 1, 5), z = c(2, 3, 1)) # Compute the mean of x, y, z in each row df |> rowwise() |> mutate(m = mean(c(x, y, z))) #> shape: (3, 4) #> ┌─────┬─────┬─────┬──────────┐ #> │ x ┆ y ┆ z ┆ m │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╪══════════╡ #> │ 1.0 ┆ 2.0 ┆ 2.0 ┆ 1.666667 │ #> │ 3.0 ┆ 1.0 ┆ 3.0 ┆ 2.333333 │ #> │ 4.0 ┆ 5.0 ┆ 1.0 ┆ 3.333333 │ #> └─────┴─────┴─────┴──────────┘ #> #> Rowwise: TRUE # Compute the min and max of x and y in each row df |> rowwise() |> mutate(min = min(c(x, y)), max = max(c(x, y))) #> shape: (3, 5) #> ┌─────┬─────┬─────┬─────┬─────┐ #> │ x ┆ y ┆ z ┆ min ┆ max │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╪═════╪═════╡ #> │ 1.0 ┆ 2.0 ┆ 2.0 ┆ 1.0 ┆ 2.0 │ #> │ 3.0 ┆ 1.0 ┆ 3.0 ┆ 1.0 ┆ 3.0 │ #> │ 4.0 ┆ 5.0 ┆ 1.0 ┆ 4.0 ┆ 5.0 │ #> └─────┴─────┴─────┴─────┴─────┘ #> #> Rowwise: TRUE"},{"path":"https://tidypolars.etiennebacher.com/reference/select.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Select columns from a Data/LazyFrame — select.RPolarsDataFrame","title":"Select columns from a Data/LazyFrame — select.RPolarsDataFrame","text":"Select columns Data/LazyFrame","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/select.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select columns from a Data/LazyFrame — select.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' select(.data, ...) # S3 method for class 'RPolarsLazyFrame' select(.data, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/select.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select columns from a Data/LazyFrame — select.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. Renaming also possible.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/select.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select columns from a Data/LazyFrame — select.RPolarsDataFrame","text":"","code":"pl_iris <- polars::as_polars_df(iris) select(pl_iris, c(\"Sepal.Length\", \"Sepal.Width\")) #> shape: (150, 2) #> ┌──────────────┬─────────────┐ #> │ Sepal.Length ┆ Sepal.Width │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════════════╪═════════════╡ #> │ 5.1 ┆ 3.5 │ #> │ 4.9 ┆ 3.0 │ #> │ 4.7 ┆ 3.2 │ #> │ 4.6 ┆ 3.1 │ #> │ 5.0 ┆ 3.6 │ #> │ … ┆ … │ #> │ 6.7 ┆ 3.0 │ #> │ 6.3 ┆ 2.5 │ #> │ 6.5 ┆ 3.0 │ #> │ 6.2 ┆ 3.4 │ #> │ 5.9 ┆ 3.0 │ #> └──────────────┴─────────────┘ select(pl_iris, Sepal.Length, Sepal.Width) #> shape: (150, 2) #> ┌──────────────┬─────────────┐ #> │ Sepal.Length ┆ Sepal.Width │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════════════╪═════════════╡ #> │ 5.1 ┆ 3.5 │ #> │ 4.9 ┆ 3.0 │ #> │ 4.7 ┆ 3.2 │ #> │ 4.6 ┆ 3.1 │ #> │ 5.0 ┆ 3.6 │ #> │ … ┆ … │ #> │ 6.7 ┆ 3.0 │ #> │ 6.3 ┆ 2.5 │ #> │ 6.5 ┆ 3.0 │ #> │ 6.2 ┆ 3.4 │ #> │ 5.9 ┆ 3.0 │ #> └──────────────┴─────────────┘ select(pl_iris, 1:3) #> shape: (150, 3) #> ┌──────────────┬─────────────┬──────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 │ #> │ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 │ #> └──────────────┴─────────────┴──────────────┘ select(pl_iris, starts_with(\"Sepal\")) #> shape: (150, 2) #> ┌──────────────┬─────────────┐ #> │ Sepal.Length ┆ Sepal.Width │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════════════╪═════════════╡ #> │ 5.1 ┆ 3.5 │ #> │ 4.9 ┆ 3.0 │ #> │ 4.7 ┆ 3.2 │ #> │ 4.6 ┆ 3.1 │ #> │ 5.0 ┆ 3.6 │ #> │ … ┆ … │ #> │ 6.7 ┆ 3.0 │ #> │ 6.3 ┆ 2.5 │ #> │ 6.5 ┆ 3.0 │ #> │ 6.2 ┆ 3.4 │ #> │ 5.9 ┆ 3.0 │ #> └──────────────┴─────────────┘ select(pl_iris, -ends_with(\"Length\")) #> shape: (150, 3) #> ┌─────────────┬─────────────┬───────────┐ #> │ Sepal.Width ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ cat │ #> ╞═════════════╪═════════════╪═══════════╡ #> │ 3.5 ┆ 0.2 ┆ setosa │ #> │ 3.0 ┆ 0.2 ┆ setosa │ #> │ 3.2 ┆ 0.2 ┆ setosa │ #> │ 3.1 ┆ 0.2 ┆ setosa │ #> │ 3.6 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … │ #> │ 3.0 ┆ 2.3 ┆ virginica │ #> │ 2.5 ┆ 1.9 ┆ virginica │ #> │ 3.0 ┆ 2.0 ┆ virginica │ #> │ 3.4 ┆ 2.3 ┆ virginica │ #> │ 3.0 ┆ 1.8 ┆ virginica │ #> └─────────────┴─────────────┴───────────┘ # Renaming while selecting is also possible select(pl_iris, foo1 = Sepal.Length, Sepal.Width) #> shape: (150, 2) #> ┌──────┬─────────────┐ #> │ foo1 ┆ Sepal.Width │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════╪═════════════╡ #> │ 5.1 ┆ 3.5 │ #> │ 4.9 ┆ 3.0 │ #> │ 4.7 ┆ 3.2 │ #> │ 4.6 ┆ 3.1 │ #> │ 5.0 ┆ 3.6 │ #> │ … ┆ … │ #> │ 6.7 ┆ 3.0 │ #> │ 6.3 ┆ 2.5 │ #> │ 6.5 ┆ 3.0 │ #> │ 6.2 ┆ 3.4 │ #> │ 5.9 ┆ 3.0 │ #> └──────┴─────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/semi_join.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Filtering joins — semi_join.RPolarsDataFrame","title":"Filtering joins — semi_join.RPolarsDataFrame","text":"Filtering joins filter rows x based presence absence matches y: semi_join() return rows x match y. anti_join() return rows x without match y.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/semi_join.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filtering joins — semi_join.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' semi_join(x, y, by = NULL, ..., na_matches = \"na\") # S3 method for class 'RPolarsDataFrame' anti_join(x, y, by = NULL, ..., na_matches = \"na\") # S3 method for class 'RPolarsLazyFrame' semi_join(x, y, by = NULL, ..., na_matches = \"na\") # S3 method for class 'RPolarsLazyFrame' anti_join(x, y, by = NULL, ..., na_matches = \"na\")"},{"path":"https://tidypolars.etiennebacher.com/reference/semi_join.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filtering joins — semi_join.RPolarsDataFrame","text":"x, y Two Polars Data/LazyFrames Variables join . NULL (default), *_join() perform natural join, using variables common across x y. message lists variables can check correct; suppress message supplying explicitly. can take character vector, like c(\"x\", \"y\") x y datasets. join variables name, use equalities character vector, like c(\"x1\" = \"x2\", \"y\"). use character vector, join can done using strict equality. can also specification created dplyr::join_by(). Contrary input character vector shown , join_by() uses unquoted column names, e.g join_by(x1 == x2, y). Finally, inner_join() also supports inequality joins, e.g. join_by(x1 >= x2), helpers (), overlaps(), within(). See documentation dplyr::join_by() information. join types likely support inequality joins future. ... Dots empty. na_matches two NA values match? \"na\", default, treats two NA values equal. \"never\" treats two NA values different never match together values. Note joining Polars Data/LazyFrames, NaN always considered equal, matter value na_matches. differs original dplyr implementation.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/semi_join.RPolarsDataFrame.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Filtering joins — semi_join.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/semi_join.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Filtering joins — semi_join.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame( x = c(1, 2, 3), y = c(1, 2, 3), z = c(1, 2, 3) ) test2 <- polars::pl$DataFrame( x = c(1, 2, 4), y = c(1, 2, 4), z2 = c(1, 2, 4) ) test #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 │ #> └─────┴─────┴─────┘ test2 #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ z2 │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 │ #> │ 4.0 ┆ 4.0 ┆ 4.0 │ #> └─────┴─────┴─────┘ # only keep the rows of `test` that have matching keys in `test2` semi_join(test, test2, by = c(\"x\", \"y\")) #> shape: (2, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 │ #> └─────┴─────┴─────┘ # only keep the rows of `test` that don't have matching keys in `test2` anti_join(test, test2, by = c(\"x\", \"y\")) #> shape: (1, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 3.0 ┆ 3.0 ┆ 3.0 │ #> └─────┴─────┴─────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/separate.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Separate a character column into multiple columns based on a substring — separate.RPolarsDataFrame","title":"Separate a character column into multiple columns based on a substring — separate.RPolarsDataFrame","text":"Currently, splitting column regular expression position possible.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/separate.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Separate a character column into multiple columns based on a substring — separate.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' separate(data, col, into, sep = \" \", remove = TRUE, ...) # S3 method for class 'RPolarsLazyFrame' separate(data, col, into, sep = \" \", remove = TRUE, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/separate.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Separate a character column into multiple columns based on a substring — separate.RPolarsDataFrame","text":"data Polars Data/LazyFrame col Column split Character vector containing names new variables create. Use NA omit variable output. sep String used split column. Regular expressions supported yet. remove TRUE, remove input column output data frame. ... Dots empty.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/separate.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Separate a character column into multiple columns based on a substring — separate.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame( x = c(NA, \"x.y\", \"x.z\", \"y.z\") ) separate(test, x, into = c(\"foo\", \"foo2\"), sep = \".\") #> shape: (4, 2) #> ┌──────┬──────┐ #> │ foo ┆ foo2 │ #> │ --- ┆ --- │ #> │ str ┆ str │ #> ╞══════╪══════╡ #> │ null ┆ null │ #> │ x ┆ y │ #> │ x ┆ z │ #> │ y ┆ z │ #> └──────┴──────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_csv.html","id":null,"dir":"Reference","previous_headings":"","what":"Stream output to a CSV file — sink_csv","title":"Stream output to a CSV file — sink_csv","text":"function allows stream LazyFrame larger RAM directly .csv file without collecting R session, thus preventing crashes small memory.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_csv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stream output to a CSV file — sink_csv","text":"","code":"sink_csv( .data, path, ..., include_bom = FALSE, include_header = TRUE, separator = \",\", line_terminator = \"\\n\", quote = \"\\\"\", batch_size = 1024, datetime_format = NULL, date_format = NULL, time_format = NULL, float_precision = NULL, null_values = \"\", quote_style = \"necessary\", maintain_order = TRUE, type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, no_optimization = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_csv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stream output to a CSV file — sink_csv","text":".data Polars LazyFrame. path Output file (must .csv file). ... Ignored. include_bom Whether include UTF-8 BOM (byte order mark) CSV output. include_header Whether include header CSV output. separator Separate CSV fields symbol. line_terminator String used end row. quote Byte use quoting character. batch_size Number rows processed per thread. datetime_format, date_format, time_format format string used format date time values. See ?strptime() accepted values. format specified, default fractional-second precision inferred maximum time unit found Datetime cols (). float_precision Number decimal places write, applied Float32 Float64 datatypes. null_values string representing null values (defaulting empty string). quote_style Determines quoting strategy used: \"necessary\" (default): puts quotes around fields necessary. necessary fields contain quote, delimiter record terminator. Quotes also necessary writing empty record (indistinguishable record one empty field). \"always\": puts quotes around every field. \"non_numeric\": puts quotes around fields non-numeric. Namely, writing field parse valid float integer, quotes used even strictly necessary. maintain_order Whether maintain order data processed (default TRUE). Setting FALSE slightly faster. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_csv.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Stream output to a CSV file — sink_csv","text":"input LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_csv.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Stream output to a CSV file — sink_csv","text":"","code":"if (FALSE) { # \\dontrun{ # This is an example workflow where sink_csv() is not very useful because # the data would fit in memory. It simply is an example of using it at the # end of a piped workflow. # Create files for the CSV input and output: file_csv <- tempfile(fileext = \".csv\") file_csv2 <- tempfile(fileext = \".csv\") # Write some data in a CSV file fake_data <- do.call(\"rbind\", rep(list(mtcars), 1000)) write.csv(fake_data, file = file_csv, row.names = FALSE) # In a new R session, we could read this file as a LazyFrame, do some operations, # and write it to another CSV file without ever collecting it in the R session: scan_csv_polars(file_csv) |> filter(cyl %in% c(4, 6), mpg > 22) |> mutate( hp_gear_ratio = hp / gear ) |> sink_csv(path = file_csv2) } # }"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ipc.html","id":null,"dir":"Reference","previous_headings":"","what":"Stream output to an IPC file — sink_ipc","title":"Stream output to an IPC file — sink_ipc","text":"function allows stream LazyFrame larger RAM directly IPC file without collecting R session, thus preventing crashes small memory.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ipc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stream output to an IPC file — sink_ipc","text":"","code":"sink_ipc( .data, path, ..., compression = \"zstd\", maintain_order = TRUE, type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, no_optimization = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ipc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stream output to an IPC file — sink_ipc","text":".data Polars LazyFrame. path Output file. ... Ignored. compression NULL character compression method, \"uncompressed\" \"lz4\" \"zstd\". NULL equivalent \"uncompressed\". Choose \"zstd\" good compression performance. Choose \"lz4\" fast compression/decompression. maintain_order Whether maintain order data processed (default TRUE). Setting FALSE slightly faster. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ipc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Stream output to an IPC file — sink_ipc","text":"input LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ndjson.html","id":null,"dir":"Reference","previous_headings":"","what":"Stream output to a NDJSON file — sink_ndjson","title":"Stream output to a NDJSON file — sink_ndjson","text":"writes output query directly NDJSON file without collecting R session first. useful output query still larger RAM crash R session collected R.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ndjson.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stream output to a NDJSON file — sink_ndjson","text":"","code":"sink_ndjson( .data, path, ..., maintain_order = TRUE, type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, no_optimization = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ndjson.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stream output to a NDJSON file — sink_ndjson","text":".data Polars LazyFrame. path Output file. ... Ignored. maintain_order Whether maintain order data processed (default TRUE). Setting FALSE slightly faster. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ndjson.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Stream output to a NDJSON file — sink_ndjson","text":"input LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_parquet.html","id":null,"dir":"Reference","previous_headings":"","what":"Stream output to a parquet file — sink_parquet","title":"Stream output to a parquet file — sink_parquet","text":"function allows stream LazyFrame larger RAM directly .parquet file without collecting R session, thus preventing crashes small memory.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_parquet.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stream output to a parquet file — sink_parquet","text":"","code":"sink_parquet( .data, path, ..., compression = \"zstd\", compression_level = 3, statistics = FALSE, row_group_size = NULL, data_page_size = NULL, maintain_order = TRUE, type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, no_optimization = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_parquet.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stream output to a parquet file — sink_parquet","text":".data Polars LazyFrame. path Output file (must .parquet file). ... Ignored. compression compression method. One : \"uncompressed\" \"zstd\" (default): good compression performance \"lz4\": fast compression / decompression \"snappy\": backwards compatibility guarantees deal older parquet readers. \"gzip\", \"lzo\", \"brotli\" compression_level level compression use (default 3). used compression one \"gzip\", \"brotli\", \"zstd\". Higher compression means smaller files disk. \"gzip\" : min-level = 0, max-level = 10 \"brotli\" : min-level = 0, max-level = 11 \"zstd\" : min-level = 1, max-level = 22. statistics Whether compute write column statistics (default FALSE). requires computations. row_group_size Size row groups number rows. NULL (default), chunks DataFrame used. Writing smaller chunks may reduce memory pressure improve writing speeds. data_page_size NULL (default), limit around 1MB. maintain_order Whether maintain order data processed (default TRUE). Setting FALSE slightly faster. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_parquet.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Stream output to a parquet file — sink_parquet","text":"input LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_parquet.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Stream output to a parquet file — sink_parquet","text":"","code":"if (FALSE) { # \\dontrun{ # This is an example workflow where sink_parquet() is not very useful because # the data would fit in memory. It simply is an example of using it at the # end of a piped workflow. # Create files for the CSV input and the Parquet output: file_csv <- tempfile(fileext = \".csv\") file_parquet <- tempfile(fileext = \".parquet\") # Write some data in a CSV file fake_data <- do.call(\"rbind\", rep(list(mtcars), 1000)) write.csv(fake_data, file = file_csv, row.names = FALSE) # In a new R session, we could read this file as a LazyFrame, do some operations, # and write it to a parquet file without ever collecting it in the R session: scan_csv_polars(file_csv) |> filter(cyl %in% c(4, 6), mpg > 22) |> mutate( hp_gear_ratio = hp / gear ) |> sink_parquet(path = file_parquet) } # }"},{"path":"https://tidypolars.etiennebacher.com/reference/slice_tail.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","title":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","text":"Subset rows Data/LazyFrame","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/slice_tail.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' slice_tail(.data, ..., n, by = NULL) # S3 method for class 'RPolarsLazyFrame' slice_tail(.data, ..., n, by = NULL) # S3 method for class 'RPolarsDataFrame' slice_head(.data, ..., n, by = NULL) # S3 method for class 'RPolarsLazyFrame' slice_head(.data, ..., n, by = NULL) # S3 method for class 'RPolarsDataFrame' slice_sample(.data, ..., n = NULL, prop = NULL, by = NULL, replace = FALSE)"},{"path":"https://tidypolars.etiennebacher.com/reference/slice_tail.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Dots empty. n number rows select start end data. used prop. Optionally, selection columns group just operation, functioning alternative group_by(). group order maintained, use group_by() want control . prop Proportion rows select. used n. replace Perform sampling replacement (TRUE) without (FALSE).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/slice_tail.RPolarsDataFrame.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/slice_tail.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","text":"","code":"pl_test <- polars::as_polars_df(iris) slice_head(pl_test, n = 3) #> shape: (3, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬─────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴─────────┘ slice_tail(pl_test, n = 3) #> shape: (3, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ slice_sample(pl_test, n = 5) #> shape: (5, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪════════════╡ #> │ 6.4 ┆ 2.8 ┆ 5.6 ┆ 2.2 ┆ virginica │ #> │ 5.0 ┆ 3.4 ┆ 1.6 ┆ 0.4 ┆ setosa │ #> │ 6.0 ┆ 2.7 ┆ 5.1 ┆ 1.6 ┆ versicolor │ #> │ 6.2 ┆ 2.8 ┆ 4.8 ┆ 1.8 ┆ virginica │ #> │ 5.4 ┆ 3.9 ┆ 1.7 ┆ 0.4 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴────────────┘ slice_sample(pl_test, prop = 0.1) #> shape: (15, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪════════════╡ #> │ 4.7 ┆ 3.2 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 5.6 ┆ 2.9 ┆ 3.6 ┆ 1.3 ┆ versicolor │ #> │ 6.6 ┆ 2.9 ┆ 4.6 ┆ 1.3 ┆ versicolor │ #> │ 5.0 ┆ 3.5 ┆ 1.6 ┆ 0.6 ┆ setosa │ #> │ 5.8 ┆ 4.0 ┆ 1.2 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 5.0 ┆ 3.0 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 7.7 ┆ 2.8 ┆ 6.7 ┆ 2.0 ┆ virginica │ #> │ 6.7 ┆ 3.1 ┆ 4.7 ┆ 1.5 ┆ versicolor │ #> │ 6.7 ┆ 3.1 ┆ 4.4 ┆ 1.4 ┆ versicolor │ #> │ 6.4 ┆ 3.2 ┆ 4.5 ┆ 1.5 ┆ versicolor │ #> └──────────────┴─────────────┴──────────────┴─────────────┴────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/summarize.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize each group down to one row — summarize.RPolarsDataFrame","title":"Summarize each group down to one row — summarize.RPolarsDataFrame","text":"summarize() returns one row combination grouping variables (one difference dplyr::summarize() summarize() accepts grouped data). contain one column grouping variable one column summary statistics specified.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/summarize.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize each group down to one row — summarize.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' summarize(.data, ..., .by = NULL, .groups = \"drop_last\") # S3 method for class 'RPolarsDataFrame' summarise(.data, ..., .by = NULL, .groups = \"drop_last\") # S3 method for class 'RPolarsLazyFrame' summarize(.data, ..., .by = NULL, .groups = \"drop_last\") # S3 method for class 'RPolarsLazyFrame' summarise(.data, ..., .by = NULL, .groups = \"drop_last\")"},{"path":"https://tidypolars.etiennebacher.com/reference/summarize.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize each group down to one row — summarize.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Name-value pairs. name gives name column output. value can : vector length current group (whole data frame ungrouped). NULL, remove column. across() mostly supported, except cases. particular, .cols argument (...), select variables created across(). select helpers supported. See examples. .Optionally, selection columns group just operation, functioning alternative group_by(). group order maintained, use group_by() want control . .groups Grouping structure result. Must one : \"drop_last\" (default): drop last level grouping; \"drop\": levels grouping dropped; \"keep\": keep grouping structure .data. now, \"rowwise\" supported. Note dplyr uses .groups = NULL default, whose behavior depends number rows group output. However, returning several rows group summarize() deprecated (one use reframe() instead), .groups = NULL supported tidypolars.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/summarize.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize each group down to one row — summarize.RPolarsDataFrame","text":"","code":"mtcars |> as_polars_df() |> group_by(cyl) |> summarize(m_gear = mean(gear), sd_gear = sd(gear)) #> shape: (3, 3) #> ┌─────┬──────────┬──────────┐ #> │ cyl ┆ m_gear ┆ sd_gear │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪══════════╪══════════╡ #> │ 8.0 ┆ 3.285714 ┆ 0.726273 │ #> │ 4.0 ┆ 4.090909 ┆ 0.53936 │ #> │ 6.0 ┆ 3.857143 ┆ 0.690066 │ #> └─────┴──────────┴──────────┘ # an alternative syntax is to use `.by` mtcars |> as_polars_df() |> summarize(m_gear = mean(gear), sd_gear = sd(gear), .by = cyl) #> shape: (3, 3) #> ┌─────┬──────────┬──────────┐ #> │ cyl ┆ m_gear ┆ sd_gear │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪══════════╪══════════╡ #> │ 8.0 ┆ 3.285714 ┆ 0.726273 │ #> │ 6.0 ┆ 3.857143 ┆ 0.690066 │ #> │ 4.0 ┆ 4.090909 ┆ 0.53936 │ #> └─────┴──────────┴──────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/summary.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Summary statistics for a Polars DataFrame — summary.RPolarsDataFrame","title":"Summary statistics for a Polars DataFrame — summary.RPolarsDataFrame","text":"Summary statistics Polars DataFrame","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/summary.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summary statistics for a Polars DataFrame — summary.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' summary(object, percentiles = c(0.25, 0.75), ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/summary.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summary statistics for a Polars DataFrame — summary.RPolarsDataFrame","text":"object Polars DataFrame. percentiles One percentiles include summary statistics. values must 0 1 (NULL ignored). ... Ignored.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/summary.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summary statistics for a Polars DataFrame — summary.RPolarsDataFrame","text":"","code":"mtcars |> as_polars_df() |> summary(percentiles = c(0.2, 0.4, 0.6, 0.8)) #> shape: (11, 12) #> ┌────────────┬───────────┬──────────┬────────────┬───┬──────────┬──────────┬──────────┬────────┐ #> │ statistic ┆ mpg ┆ cyl ┆ disp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞════════════╪═══════════╪══════════╪════════════╪═══╪══════════╪══════════╪══════════╪════════╡ #> │ count ┆ 32.0 ┆ 32.0 ┆ 32.0 ┆ … ┆ 32.0 ┆ 32.0 ┆ 32.0 ┆ 32.0 │ #> │ null_count ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> │ mean ┆ 20.090625 ┆ 6.1875 ┆ 230.721875 ┆ … ┆ 0.4375 ┆ 0.40625 ┆ 3.6875 ┆ 2.8125 │ #> │ std ┆ 6.026948 ┆ 1.785922 ┆ 123.938694 ┆ … ┆ 0.504016 ┆ 0.498991 ┆ 0.737804 ┆ 1.6152 │ #> │ min ┆ 10.4 ┆ 4.0 ┆ 71.1 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 40% ┆ 17.8 ┆ 6.0 ┆ 160.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ 50% ┆ 19.2 ┆ 6.0 ┆ 225.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ 60% ┆ 21.0 ┆ 8.0 ┆ 275.8 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 3.0 │ #> │ 80% ┆ 24.4 ┆ 8.0 ┆ 351.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ max ┆ 33.9 ┆ 8.0 ┆ 472.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> └────────────┴───────────┴──────────┴────────────┴───┴──────────┴──────────┴──────────┴────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/tidypolars-options.html","id":null,"dir":"Reference","previous_headings":"","what":"tidypolars global options — tidypolars-options","title":"tidypolars global options — tidypolars-options","text":"currently one global option: tidypolars_unknown_args controls happens arguments passed expression unknown, e.g argument prob sample(). default (\"warn\") warns user arguments ignored tidypolars. accepted value \"error\" throw error happens.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/tidypolars-options.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"tidypolars global options — tidypolars-options","text":"","code":"options(tidypolars_unknown_args = \"warn\") test <- polars::pl$DataFrame(x = c(2, 1, 5, 3, 1)) # The default is to warn the user mutate(test, x2 = sample(x, prob = 0.5)) #> Warning: #> Package tidypolars doesn't know how to use some arguments of `sample()`. #> The following argument(s) will be ignored: `prob`. #> shape: (5, 2) #> ┌─────┬─────┐ #> │ x ┆ x2 │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞═════╪═════╡ #> │ 2.0 ┆ 2.0 │ #> │ 1.0 ┆ 3.0 │ #> │ 5.0 ┆ 5.0 │ #> │ 3.0 ┆ 1.0 │ #> │ 1.0 ┆ 1.0 │ #> └─────┴─────┘ # But one can make this stricter and throw an error when this happens options(tidypolars_unknown_args = \"error\") try(mutate(test, x2 = sample(x, prob = 0.5))) #> Error in mutate(test, x2 = sample(x, prob = 0.5)) : #> Error while running function `sample()` in Polars. #> ✖ Package tidypolars doesn't know how to use some arguments of `sample()`: `prob`. #> ℹ Use `options(tidypolars_unknown_args = \"warn\")` to warn when this happens instead of throwing an error. options(tidypolars_unknown_args = \"warn\")"},{"path":"https://tidypolars.etiennebacher.com/reference/tidypolars-package.html","id":null,"dir":"Reference","previous_headings":"","what":"tidypolars: Get the Power of Polars with the Syntax of the Tidyverse — tidypolars-package","title":"tidypolars: Get the Power of Polars with the Syntax of the Tidyverse — tidypolars-package","text":"Polars amazing cross-language tool manipulating large data. However, one drawback R implementation syntax look odd many R users used Python syntax. objective tidypolars improve ease--use Polars R providing tidyverse syntax polars.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/reference/tidypolars-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"tidypolars: Get the Power of Polars with the Syntax of the Tidyverse — tidypolars-package","text":"Maintainer: Etienne Bacher etienne.bacher@protonmail.com [copyright holder]","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/uncount.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Uncount a Data/LazyFrame — uncount.RPolarsDataFrame","title":"Uncount a Data/LazyFrame — uncount.RPolarsDataFrame","text":"duplicates rows according weighting variable (expression). opposite count().","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/uncount.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Uncount a Data/LazyFrame — uncount.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' uncount(data, weights, ..., .remove = TRUE, .id = NULL) # S3 method for class 'RPolarsLazyFrame' uncount(data, weights, ..., .remove = TRUE, .id = NULL)"},{"path":"https://tidypolars.etiennebacher.com/reference/uncount.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Uncount a Data/LazyFrame — uncount.RPolarsDataFrame","text":"data Polars Data/LazyFrame weights vector weights. Evaluated context data. ... Dots empty. .remove TRUE, weights name column data, column removed. .id Supply string create new variable gives unique identifier created row.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/uncount.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Uncount a Data/LazyFrame — uncount.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame(x = c(\"a\", \"b\"), y = 100:101, n = c(1, 2)) test #> shape: (2, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ n │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ a ┆ 100 ┆ 1.0 │ #> │ b ┆ 101 ┆ 2.0 │ #> └─────┴─────┴─────┘ uncount(test, n) #> shape: (3, 2) #> ┌─────┬─────┐ #> │ x ┆ y │ #> │ --- ┆ --- │ #> │ str ┆ i32 │ #> ╞═════╪═════╡ #> │ a ┆ 100 │ #> │ b ┆ 101 │ #> │ b ┆ 101 │ #> └─────┴─────┘ uncount(test, n, .id = \"id\") #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ id │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ u32 │ #> ╞═════╪═════╪═════╡ #> │ a ┆ 100 ┆ 1 │ #> │ b ┆ 101 ┆ 1 │ #> │ b ┆ 101 ┆ 2 │ #> └─────┴─────┴─────┘ # using constants uncount(test, 2) #> shape: (4, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ n │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ a ┆ 100 ┆ 1.0 │ #> │ a ┆ 100 ┆ 1.0 │ #> │ b ┆ 101 ┆ 2.0 │ #> │ b ┆ 101 ┆ 2.0 │ #> └─────┴─────┴─────┘ # using expressions uncount(test, 2 / n) #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ n │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ a ┆ 100 ┆ 1.0 │ #> │ a ┆ 100 ┆ 1.0 │ #> │ b ┆ 101 ┆ 2.0 │ #> └─────┴─────┴─────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/unite.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Unite multiple columns into one by pasting strings together — unite.RPolarsDataFrame","title":"Unite multiple columns into one by pasting strings together — unite.RPolarsDataFrame","text":"Unite multiple columns one pasting strings together","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/unite.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Unite multiple columns into one by pasting strings together — unite.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' unite(data, col, ..., sep = \"_\", remove = TRUE, na.rm = FALSE) # S3 method for class 'RPolarsLazyFrame' unite(data, col, ..., sep = \"_\", remove = TRUE, na.rm = FALSE)"},{"path":"https://tidypolars.etiennebacher.com/reference/unite.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Unite multiple columns into one by pasting strings together — unite.RPolarsDataFrame","text":"data Polars Data/LazyFrame col name new column, string symbol. ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. sep Separator use values. remove TRUE, remove input columns output Data/LazyFrame. na.rm TRUE, missing values replaced empty string prior uniting value.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/unite.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Unite multiple columns into one by pasting strings together — unite.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame( year = 2009:2011, month = 10:12, day = c(11L, 22L, 28L), name_day = c(\"Monday\", \"Thursday\", \"Wednesday\") ) # By default, united columns are dropped unite(test, col = \"full_date\", year, month, day, sep = \"-\") #> shape: (3, 2) #> ┌───────────┬────────────┐ #> │ name_day ┆ full_date │ #> │ --- ┆ --- │ #> │ str ┆ str │ #> ╞═══════════╪════════════╡ #> │ Monday ┆ 2009-10-11 │ #> │ Thursday ┆ 2010-11-22 │ #> │ Wednesday ┆ 2011-12-28 │ #> └───────────┴────────────┘ unite(test, col = \"full_date\", year, month, day, sep = \"-\", remove = FALSE) #> shape: (3, 5) #> ┌──────┬───────┬─────┬───────────┬────────────┐ #> │ year ┆ month ┆ day ┆ name_day ┆ full_date │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ i32 ┆ i32 ┆ i32 ┆ str ┆ str │ #> ╞══════╪═══════╪═════╪═══════════╪════════════╡ #> │ 2009 ┆ 10 ┆ 11 ┆ Monday ┆ 2009-10-11 │ #> │ 2010 ┆ 11 ┆ 22 ┆ Thursday ┆ 2010-11-22 │ #> │ 2011 ┆ 12 ┆ 28 ┆ Wednesday ┆ 2011-12-28 │ #> └──────┴───────┴─────┴───────────┴────────────┘ test2 <- polars::pl$DataFrame( name = c(\"John\", \"Jack\", \"Thomas\"), middlename = c(\"T.\", NA, \"F.\"), surname = c(\"Smith\", \"Thompson\", \"Jones\") ) # By default, NA values are kept in the character output unite(test2, col = \"full_name\", everything(), sep = \" \") #> shape: (3, 1) #> ┌──────────────────┐ #> │ full_name │ #> │ --- │ #> │ str │ #> ╞══════════════════╡ #> │ John T. Smith │ #> │ Jack NA Thompson │ #> │ Thomas F. Jones │ #> └──────────────────┘ unite(test2, col = \"full_name\", everything(), sep = \" \", na.rm = TRUE) #> shape: (3, 1) #> ┌─────────────────┐ #> │ full_name │ #> │ --- │ #> │ str │ #> ╞═════════════════╡ #> │ John T. Smith │ #> │ Jack Thompson │ #> │ Thomas F. Jones │ #> └─────────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/write_csv_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Export data to CSV file(s) — write_csv_polars","title":"Export data to CSV file(s) — write_csv_polars","text":"Export data CSV file(s)","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_csv_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export data to CSV file(s) — write_csv_polars","text":"","code":"write_csv_polars( .data, file, ..., include_bom = FALSE, include_header = TRUE, separator = \",\", line_terminator = \"\\n\", quote = \"\\\"\", batch_size = 1024, datetime_format = NULL, date_format = NULL, time_format = NULL, float_precision = NULL, null_values = \"\", quote_style = \"necessary\" )"},{"path":"https://tidypolars.etiennebacher.com/reference/write_csv_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export data to CSV file(s) — write_csv_polars","text":".data Polars DataFrame. file File path result written. ... Ignored. include_bom Whether include UTF-8 BOM (byte order mark) CSV output. include_header Whether include header CSV output. separator Separate CSV fields symbol. line_terminator String used end row. quote Byte use quoting character. batch_size Number rows processed per thread. datetime_format format string, specifiers defined chrono Rust crate. format specified, default fractional-second precision inferred maximum timeunit found frame’s Datetime cols (). date_format format string, specifiers defined chrono Rust crate. time_format format string, specifiers defined chrono Rust crate. float_precision Number decimal places write, applied Float32 Float64 datatypes. null_values string representing null values (defaulting empty string). quote_style Determines quoting strategy used. \"necessary\" (default): puts quotes around fields necessary. necessary fields contain quote, delimiter record terminator. Quotes also necessary writing empty record (indistinguishable record one empty field). default. \"always\": puts quotes around every field. \"non_numeric\": puts quotes around fields non-numeric. Namely, writing field parse valid float integer, quotes used even aren`t strictly necessary. \"never\": never puts quotes around fields, even results invalid CSV data (e.g. quoting strings containing separator).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_csv_polars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Export data to CSV file(s) — write_csv_polars","text":"input DataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_csv_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export data to CSV file(s) — write_csv_polars","text":"","code":"dest <- tempfile(fileext = \".csv\") mtcars |> as_polars_df() |> write_csv_polars(dest) read.csv(dest) #> mpg cyl disp hp drat wt qsec vs am gear carb #> 1 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4 #> 2 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4 #> 3 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 #> 4 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 #> 5 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2 #> 6 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1 #> 7 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4 #> 8 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2 #> 9 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2 #> 10 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4 #> 11 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4 #> 12 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3 #> 13 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3 #> 14 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3 #> 15 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4 #> 16 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4 #> 17 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4 #> 18 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1 #> 19 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2 #> 20 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1 #> 21 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1 #> 22 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2 #> 23 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2 #> 24 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4 #> 25 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2 #> 26 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1 #> 27 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2 #> 28 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2 #> 29 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4 #> 30 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6 #> 31 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8 #> 32 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2"},{"path":"https://tidypolars.etiennebacher.com/reference/write_ipc_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Export data to IPC file(s) — write_ipc_polars","title":"Export data to IPC file(s) — write_ipc_polars","text":"Export data IPC file(s)","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_ipc_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export data to IPC file(s) — write_ipc_polars","text":"","code":"write_ipc_polars( .data, file, compression = \"uncompressed\", ..., future = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/write_ipc_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export data to IPC file(s) — write_ipc_polars","text":".data Polars DataFrame. file File path result written. compression NULL character compression method, \"uncompressed\" \"lz4\" \"zstd\". NULL equivalent \"uncompressed\". Choose \"zstd\" good compression performance. Choose \"lz4\" fast compression/decompression. ... Ignored. future Setting TRUE write Polars' internal data structures might available Arrow implementations.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_ipc_polars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Export data to IPC file(s) — write_ipc_polars","text":"input DataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_json_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Export data to JSON file(s) — write_json_polars","title":"Export data to JSON file(s) — write_json_polars","text":"Export data JSON file(s)","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_json_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export data to JSON file(s) — write_json_polars","text":"","code":"write_json_polars(.data, file, ..., pretty = FALSE, row_oriented = FALSE)"},{"path":"https://tidypolars.etiennebacher.com/reference/write_json_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export data to JSON file(s) — write_json_polars","text":".data Polars DataFrame. file File path result written. ... Ignored. pretty Pretty serialize JSON. row_oriented Write row-oriented JSON. slower, common.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_json_polars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Export data to JSON file(s) — write_json_polars","text":"input DataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_json_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export data to JSON file(s) — write_json_polars","text":"","code":"dest <- tempfile(fileext = \".json\") mtcars |> as_polars_df() |> write_json_polars(dest) jsonlite::fromJSON(dest) #> $columns #> name datatype bit_settings #> 1 mpg Float64 #> 2 cyl Float64 #> 3 disp Float64 #> 4 hp Float64 #> 5 drat Float64 #> 6 wt Float64 #> 7 qsec Float64 #> 8 vs Float64 #> 9 am Float64 #> 10 gear Float64 #> 11 carb Float64 #> values #> 1 21.0, 21.0, 22.8, 21.4, 18.7, 18.1, 14.3, 24.4, 22.8, 19.2, 17.8, 16.4, 17.3, 15.2, 10.4, 10.4, 14.7, 32.4, 30.4, 33.9, 21.5, 15.5, 15.2, 13.3, 19.2, 27.3, 26.0, 30.4, 15.8, 19.7, 15.0, 21.4 #> 2 6, 6, 4, 6, 8, 6, 8, 4, 4, 6, 6, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 8, 8, 8, 8, 4, 4, 4, 8, 6, 8, 4 #> 3 160.0, 160.0, 108.0, 258.0, 360.0, 225.0, 360.0, 146.7, 140.8, 167.6, 167.6, 275.8, 275.8, 275.8, 472.0, 460.0, 440.0, 78.7, 75.7, 71.1, 120.1, 318.0, 304.0, 350.0, 400.0, 79.0, 120.3, 95.1, 351.0, 145.0, 301.0, 121.0 #> 4 110, 110, 93, 110, 175, 105, 245, 62, 95, 123, 123, 180, 180, 180, 205, 215, 230, 66, 52, 65, 97, 150, 150, 245, 175, 66, 91, 113, 264, 175, 335, 109 #> 5 3.90, 3.90, 3.85, 3.08, 3.15, 2.76, 3.21, 3.69, 3.92, 3.92, 3.92, 3.07, 3.07, 3.07, 2.93, 3.00, 3.23, 4.08, 4.93, 4.22, 3.70, 2.76, 3.15, 3.73, 3.08, 4.08, 4.43, 3.77, 4.22, 3.62, 3.54, 4.11 #> 6 2.620, 2.875, 2.320, 3.215, 3.440, 3.460, 3.570, 3.190, 3.150, 3.440, 3.440, 4.070, 3.730, 3.780, 5.250, 5.424, 5.345, 2.200, 1.615, 1.835, 2.465, 3.520, 3.435, 3.840, 3.845, 1.935, 2.140, 1.513, 3.170, 2.770, 3.570, 2.780 #> 7 16.46, 17.02, 18.61, 19.44, 17.02, 20.22, 15.84, 20.00, 22.90, 18.30, 18.90, 17.40, 17.60, 18.00, 17.98, 17.82, 17.42, 19.47, 18.52, 19.90, 20.01, 16.87, 17.30, 15.41, 17.05, 18.90, 16.70, 16.90, 14.50, 15.50, 14.60, 18.60 #> 8 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1 #> 9 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 #> 10 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 5, 4 #> 11 4, 4, 1, 1, 2, 1, 4, 2, 2, 4, 4, 3, 3, 3, 4, 4, 4, 1, 2, 1, 1, 2, 2, 4, 2, 1, 2, 2, 4, 6, 8, 2 #>"},{"path":"https://tidypolars.etiennebacher.com/reference/write_ndjson_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Export data to NDJSON file(s) — write_ndjson_polars","title":"Export data to NDJSON file(s) — write_ndjson_polars","text":"Export data NDJSON file(s)","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_ndjson_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export data to NDJSON file(s) — write_ndjson_polars","text":"","code":"write_ndjson_polars(.data, file)"},{"path":"https://tidypolars.etiennebacher.com/reference/write_ndjson_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export data to NDJSON file(s) — write_ndjson_polars","text":".data Polars DataFrame. file File path result written.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_ndjson_polars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Export data to NDJSON file(s) — write_ndjson_polars","text":"input DataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_ndjson_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export data to NDJSON file(s) — write_ndjson_polars","text":"","code":"dest <- tempfile(fileext = \".ndjson\") mtcars |> as_polars_df() |> write_ndjson_polars(dest) jsonlite::stream_in(file(dest), verbose = FALSE) #> mpg cyl disp hp drat wt qsec vs am gear carb #> 1 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4 #> 2 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4 #> 3 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 #> 4 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 #> 5 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2 #> 6 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1 #> 7 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4 #> 8 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2 #> 9 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2 #> 10 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4 #> 11 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4 #> 12 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3 #> 13 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3 #> 14 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3 #> 15 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4 #> 16 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4 #> 17 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4 #> 18 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1 #> 19 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2 #> 20 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1 #> 21 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1 #> 22 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2 #> 23 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2 #> 24 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4 #> 25 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2 #> 26 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1 #> 27 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2 #> 28 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2 #> 29 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4 #> 30 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6 #> 31 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8 #> 32 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2"},{"path":"https://tidypolars.etiennebacher.com/reference/write_parquet_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Export data to Parquet file(s) — write_parquet_polars","title":"Export data to Parquet file(s) — write_parquet_polars","text":"Export data Parquet file(s)","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_parquet_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export data to Parquet file(s) — write_parquet_polars","text":"","code":"write_parquet_polars( .data, file, ..., compression = \"zstd\", compression_level = 3, statistics = TRUE, row_group_size = NULL, data_page_size = NULL, partition_by = NULL, partition_chunk_size_bytes = 4294967296 )"},{"path":"https://tidypolars.etiennebacher.com/reference/write_parquet_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export data to Parquet file(s) — write_parquet_polars","text":".data Polars DataFrame. file File path result written. ... Ignored. compression compression method. One : \"uncompressed\" \"zstd\" (default): good compression performance \"lz4\": fast compression / decompression \"snappy\": backwards compatibility guarantees deal older parquet readers. \"gzip\", \"lzo\", \"brotli\" compression_level level compression use (default 3). used compression one \"gzip\", \"brotli\", \"zstd\". Higher compression means smaller files disk. \"gzip\" : min-level = 0, max-level = 10 \"brotli\" : min-level = 0, max-level = 11 \"zstd\" : min-level = 1, max-level = 22. statistics Whether compute write column statistics (default FALSE). requires computations. row_group_size Size row groups number rows. NULL (default), chunks DataFrame used. Writing smaller chunks may reduce memory pressure improve writing speeds. data_page_size NULL (default), limit around 1MB. partition_by Column(s) partition . partitioned dataset written specified. partition_chunk_size_bytes Approximate size split DataFrames within single partition writing. Note calculated using size DataFrame memory - size output file may differ depending file format / compression.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_parquet_polars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Export data to Parquet file(s) — write_parquet_polars","text":"input DataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_parquet_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export data to Parquet file(s) — write_parquet_polars","text":"","code":"dest <- tempfile(fileext = \".parquet\") mtcars |> as_polars_df() |> write_parquet_polars(dest) nanoparquet::read_parquet(dest) #> # A data frame: 32 × 11 #> mpg cyl disp hp drat wt qsec vs am gear carb #> #> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 #> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4 #> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1 #> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1 #> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2 #> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1 #> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4 #> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2 #> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2 #> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 #> # ℹ 22 more rows"},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-development-version","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars (development version)","text":"Added support stringr::str_replace_na() (#153). Better checks unknown unsupported arguments compute(), collect(), *_join(), pivot_*(), sink_*(), slice_sample() uncount()(#158, thanks @fkohrt report). Now, functions receive: argument exists tidyverse implementation supported tidypolars, warn user. default behaviour can changed error instead options(tidypolars_unknown_args = \"error\"). argument doesn’t exist , error.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-development-version","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars (development version)","text":"slice_sample() now errors unknown unsupported arguments passed (thanks @fkohrt report).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-0120","dir":"Changelog","previous_headings":"","what":"tidypolars 0.12.0","title":"tidypolars 0.12.0","text":"tidypolars requires polars >= 0.21.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-12-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.12.0","text":"summarize() now drops last group output default (consistency dplyr). Previously kept groups input data (#149).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-12-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.12.0","text":"Add support argument .groups summarize(). Value \"rowwise\" supported now (#149). Added support dplyr::lead(). dplyr::lead() dplyr::lag(), arguments default order_by now supported (#151).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-0110","dir":"Changelog","previous_headings":"","what":"tidypolars 0.11.0","title":"tidypolars 0.11.0","text":"tidypolars requires polars >= 0.20.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-11-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.11.0","text":"arrange() now errors unknown variable names (like dplyr::arrange()). Previously, unknown variables silently ignored. Using expressions (like + b) now accepted (#144). parameter inherit_optimization removed sink_*() functions.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-11-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.11.0","text":"power operators ^ ** now work. New function sink_ndjson() write results lazy query NDJSON file without collecting memory. inner_join() now accepts inequality joins argument, including following helpers: (), overlaps(), within() (#148).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-11-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.11.0","text":"Using external object case_when(), ifelse() ifelse() now works. str_sub() doesn’t error anymore start positive end negative. read_*_polars() functions used return standard data.frame mistake. now return Polars DataFrame. Using [ subsetting expressions now works. Thanks @ginolhac report (#141). bind_cols_polars() bind_rows_polars() now error (expected ) elements mix Polars DataFrames LazyFrames.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-10-1","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.10.1","text":"error handling columns datatype Null. Note converting columns R .data.frame(), as_tibble(), collect() still issue polars 0.19.1.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-0100","dir":"Changelog","previous_headings":"","what":"tidypolars 0.10.0","title":"tidypolars 0.10.0","text":"tidypolars requires polars >= 0.19.1.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-and-deprecations-0-10-0","dir":"Changelog","previous_headings":"","what":"Breaking changes and deprecations","title":"tidypolars 0.10.0","text":"describe() deprecated tidypolars 0.10.0 removed future update. Use summary() arguments instead (#127). describe_plan() describe_optimized_plan() deprecated tidypolars 0.10.0 removed future update. Use explain() optimized = TRUE/FALSE instead (#128). sink_parquet() sink_csv(), arguments except .data path must named (#136).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-10-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.10.0","text":"Add support functions: package base: substr(). Better error message function can come several packages one version translated (#130). row_number() now works without argument (#131). New functions import data Polars DataFrames LazyFrames (#136): read__polars() import data Polars DataFrame; scan__polars() import data Polars LazyFrame; can “csv”, “ipc”, “json”, “parquet”. can replace functions polars. example, polars::pl$read_parquet(...) can replaced read_parquet_polars(...). New functions write Polars DataFrames external files: write__polars() can “csv”, “ipc”, “json”, “ndjson”, “parquet” (#136). New function sink_ipc() similar sink_parquet() sink_csv() IPC files (#136). across() now throws better error message user passes external list .fns. works dplyr work tidypolars (#135). Added support argument .add group_by().","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-10-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.10.0","text":"stringr::str_sub() now works start end negative. Fixed bug str_sub() start greater 1. stringr::str_starts() stringr::str_ends() now work regex. fill() doesn’t error anymore ... empty. Instead, returns input data. unite() now provides proper error message col missing. unite() doesn’t error anymore ... empty. Instead, uses variables dataset. filter(), mutate() summarize() now work using column another data.frame, e.g.  replace_na() longer converts column datatype replacement, e.g. data |> replace_na(\"\") error input data numeric. n_distinct() now correctly applies na.rm argument several columns passed input (#137).","code":"my_polars_df |> filter(x %in% some_data_frame$y)"},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-090","dir":"Changelog","previous_headings":"","what":"tidypolars 0.9.0","title":"tidypolars 0.9.0","text":"tidypolars requires polars >= 0.18.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-9-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.9.0","text":"Add support several functions: package base: %% %/%. package dplyr: dense_rank(), row_number(). package lubridate: wday(). Better handling missing values match R behavior. following functions, least one missing value na.rm = FALSE (default), output NA: max(), mean(), median(), min(), sd(), sum(), var() (#120). New argument cluster_with_columns collect(), compute(), fetch(). Add global option tidypolars_unknown_args control happens tidypolars doesn’t know handle argument function. default warn accepted value \"error\".","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-9-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.9.0","text":"count() add_count() longer overwrite variable named n argument name unspecified.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-080","dir":"Changelog","previous_headings":"","what":"tidypolars 0.8.0","title":"tidypolars 0.8.0","text":"tidypolars requires polars >= 0.17.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-8-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.8.0","text":"announced tidypolars 0.7.0, behavior collect() changed. now returns standard R data.frame Polars DataFrame anymore. Replace collect() compute() (arguments) keep old behavior. bind_rows_polars(), .id passed, resulting column now type character instead integer.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-8-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.8.0","text":"Add support several functions: package base: (), (), diff(), ISOdatetime(), length(), rev(), unique(). package dplyr: consecutive_id(), min_rank(), na_if(), n_distinct(), nth(). package lubridate: make_datetime(). package stringr: str_dup(), str_split(), str_split_i(), str_trunc(). package tidyr: replace_na() (data.frame method already translated vector one can used mutate() example). now possible use explicit namespaces (dplyr::first() instead first()) mutate(), summarize() filter() (#114). bind_rows_polars(), elements named .id specified, .id column use names elements (#116). now possible rename variables select() (#117). Add support argument na_matches join functions (except cross_join() doesn’t need ) (#109).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-8-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.8.0","text":"Local variables custom functions used tidypolars functions (reported blog post Art Steinmetz). now fixed. across() now works .cols contains one variable .fns contains one function. across(), .cols argument now takes account variables created mutate() summarize() call across(). Note () function supported . example: return 0 variable foo. warning emitted behavior. Better handling negative values c() called mutate() summarize().","code":"as_polars_df(mtcars) |> head(n = 3) |> mutate( foo = 1, across(.cols = contains(\"oo\"), \\(x) x - 1) ) shape: (3, 12) ┌──────┬─────┬───────┬───────┬───┬─────┬──────┬──────┬─────┐ │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ am ┆ gear ┆ carb ┆ foo │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ ╞══════╪═════╪═══════╪═══════╪═══╪═════╪══════╪══════╪═════╡ │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 0.0 │ │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 0.0 │ │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 1.0 ┆ 0.0 │ └──────┴─────┴───────┴───────┴───┴─────┴──────┴──────┴─────┘ as_polars_df(mtcars) |> mutate( foo = 1, across(.cols = where(is.numeric), \\(x) x - 1) )"},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-070","dir":"Changelog","previous_headings":"","what":"tidypolars 0.7.0","title":"tidypolars 0.7.0","text":"tidypolars requires polars >= 0.16.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-and-deprecations-0-7-0","dir":"Changelog","previous_headings":"","what":"Breaking changes and deprecations","title":"tidypolars 0.7.0","text":"as_polars() now removed. deprecated 0.6.0. Use as_polars_df() as_polars_lf() instead. to_r() now removed. deprecated 0.6.0. Use .data.frame() as_tibble() instead. consistency dplyr, behavior collect() change 0.8.0 perform lazy query convert result standard data.frame. now, collect() throws warning future change. recommended use compute() perform query get Polars DataFrame output (#101).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-7-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.7.0","text":"Several improvements changes pivot_wider() (#95): names_from can now takes several variables; add support id_cols names_glue; default value names_sep now _, consistency tidyr; fix documentation pivot_wider() doesn’t work LazyFrame. Add support stringr::regex(). Note argument ignore_case supported now (#97). Add support several lubridate functions: dweeks(), ddays(), dhours(), dminutes(), dseconds(), dmilliseconds(), make_date() (#107). polars function called internally fails, original error message now displayed. Add support group_split() (DataFrame ). Add support argument relationship left_join(), right_join(), full_join() inner_join() (#106).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-060","dir":"Changelog","previous_headings":"","what":"tidypolars 0.6.0","title":"tidypolars 0.6.0","text":"tidypolars requires polars >= 0.15.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-and-deprecations-0-6-0","dir":"Changelog","previous_headings":"","what":"Breaking changes and deprecations","title":"tidypolars 0.6.0","text":"as_polars() deprecated removed 0.7.0. Use as_polars_lf() as_polars_df() instead. as_polars() doesn’t argument with_string_cache anymore. set TRUE, enabled string cache globally, lead undesirable side effects. to_r() deprecated removed 0.7.0. Use .data.frame() as_tibble() instead. used silently return LazyFrame input LazyFrame. now automatically collects LazyFrame (#88). pull() nows automatically collects input LazyFrame (#89).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-6-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.6.0","text":"Add support argument .keep mutate() (#80). Add support group_vars() group_keys() (#81). Experimental support rowwise(). now, limited functions: mean(), median(), min(), max(), sum(), (), (). rowwise() group_by() used time (#40). functions return polars Data/LazyFrame now add class \"tidypolars\" output (#86). Support .min(), .max(), dplyr::n(). Support .data[[ .env[[ addition .data$ .env$. Better error messages objects specified .data .env don’t exist.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-6-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.6.0","text":"pull() now errors var length > 1.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-050","dir":"Changelog","previous_headings":"","what":"tidypolars 0.5.0","title":"tidypolars 0.5.0","text":"tidypolars requires polars >= 0.12.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-5-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.5.0","text":"across() now errors argument .cols provided (either named unnamed). behavior deprecated dplyr 1.1.0. longer possible use ! arrange() sort decreasing order, compatibility dplyr::arrange(). Use - desc() instead.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-5-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.5.0","text":"summarize() now works ungrouped data returns 1-row output. now possible use desc(x1) arrange() sort decreasing order x1 (equivalent -x1). Add support argument names_prefix pivot_longer(). Add support arguments names_prefix names_sep pivot_wider(). Add support tidyr::uncount(). *_join() functions now work specification created dplyr::join_by(). Notice limited equality joins now. can now use “embrace” operator {{ }} pass unquoted column names (among things) arguments custom functions. See “Programming dplyr” vignette examples. bind_cols_polars() now works two LazyFrames, . Add support argument .name_repair bind_cols_polars() (#74). Support .env$ .data$ pronouns expressions filter(), mutate() summarize(). Support named vector argument pattern str_replace_all(), names patterns values replacements. Using %% factor variables doesn’t require enabling string cache anymore.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-5-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.5.0","text":"summarize() longer errors across(everything(), ...) used .. *_join() functions longer error named vector provided argument . Expressions values named “literal” anymore.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"misc-0-5-0","dir":"Changelog","previous_headings":"","what":"Misc","title":"tidypolars 0.5.0","text":"Simplify procedure support new functions.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-040","dir":"Changelog","previous_headings":"","what":"tidypolars 0.4.0","title":"tidypolars 0.4.0","text":"tidypolars requires polars >= 0.11.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-4-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.4.0","text":"longer possible pass list rename().","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-4-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.4.0","text":"argument with_string_cache as_polars() now enables string cache globally set TRUE (#54). Better error message filter() comparing factors strings string cache disabled. Basic support strptime(). possible use strptime(*, strict = FALSE) error parsing characters fails. New argument .filter(), mutate(), summarize(), new argument slice_*() functions. allows operations groups without using group_by() ungroup(). See dplyr vignette information (#59). rename() now accepts unquoted names old new names. Support fixed regexes str_detect() (using fixed()) grepl() (using fixed = TRUE).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-4-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.4.0","text":"Improve robustness sequential expressions mutate() summarize() (.e expressions run one depend variables created call) (#58). relocate() now works correctly .= last_col(). functions work grouped data now correctly restore groups structure (#62).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"misc-0-4-0","dir":"Changelog","previous_headings":"","what":"Misc","title":"tidypolars 0.4.0","text":"Error messages coming mutate(), summarize(), filter() now give right function call. Faster tidy selection (#61).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-030","dir":"Changelog","previous_headings":"","what":"tidypolars 0.3.0","title":"tidypolars 0.3.0","text":"tidypolars requires polars >= 0.10.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-3-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.3.0","text":"functions starting pl_ removed benefit S3 methods. example, pl_distinct() doesn’t exist anymore way use load dplyr use distinct() Polars DataFrame LazyFrame. avoid confusion compatibility dplyr tidyr. See #49 detailed explanation. pl_bind_rows() pl_bind_cols() renamed bind_rows_polars() bind_cols_polars() respectively. bind_rows() bind_cols() S3 methods (might change future versions dplyr).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-3-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.3.0","text":"New function duplicated_rows() opposite distinct() (#50). New argument .id bind_rows_polars(). bind_rows_polars() can now bind Data/LazyFrames don’t schema. Columns upcast common types necessary. Unknown columns filled NA.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-3-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.3.0","text":"complete() now works correctly grouped data.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"misc-0-3-0","dir":"Changelog","previous_headings":"","what":"Misc","title":"tidypolars 0.3.0","text":"relig_income fish_encounters reexported anymore since tidyr now imported.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-020","dir":"Changelog","previous_headings":"","what":"tidypolars 0.2.0","title":"tidypolars 0.2.0","text":"tidypolars requires polars >= 0.9.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-2-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.2.0","text":"Rename pl_fetch() fetch(). New functions supported: describe(), sink_csv(), slice_sample(). New argument fill pl_complete(). Support stringr::str_to_title() tools::toTitleCase(). Support stringr::fixed() use literal strings. Support replacements captured groups like \\\\1 stringr::str_replace() stringr::str_replace_all().","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-2-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.2.0","text":"sink_parquet() didn’t use user inputs (apart path).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"misc-0-2-0","dir":"Changelog","previous_headings":"","what":"Misc","title":"tidypolars 0.2.0","text":"Clearer error message expression contains ::. supported now potentially implemented later. pl_colnames() longer exported.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-1-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.1.0","text":"Support .numeric(), .character(), .logical(), grepl(), paste() expressions pl_filter(), pl_mutate() pl_summarize(). Support sink_parquet() (#38). Support fetch() (#42). Support additional stringr functions: str_detect(), str_extract_all(), str_pad(), str_squish(), str_trim(), word() (arguments corner cases supported yet). Add optimization parameters collect().","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-1-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.1.0","text":"Fix pl_mutate() pl_summarize() expressions use variables previously created modified (#10, #37). Fix bug pl_filter() passing vector RHS %%.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"misc-0-1-0","dir":"Changelog","previous_headings":"","what":"Misc","title":"tidypolars 0.1.0","text":"Improve backend translate R expressions Polars expressions. also led complete rewriting vignette “R Polars expressions” (#27). Error messages now report correct function call. Improve CI coverage (#35).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-001","dir":"Changelog","previous_headings":"","what":"tidypolars 0.0.1","title":"tidypolars 0.0.1","text":"First Github release.","code":""}] +[{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to tidypolars","title":"Contributing to tidypolars","text":"outlines propose change tidypolars.","code":""},{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to tidypolars","text":"Small typos grammatical errors vignettes can fixed directly Github interface since vignettes automatically rendered pkgdown. Fixing typos documentation functions (“Reference” page) requires editing source corresponding .R file run devtools::document(). edit .Rd file man/.","code":""},{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":"filing-an-issue","dir":"","previous_headings":"","what":"Filing an issue","title":"Contributing to tidypolars","text":"easiest way propose change new feature file issue. ’ve found bug, may also create associated issue. possible, try illustrate proposal bug minimal reproducible example.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":"general-information","dir":"","previous_headings":"Pull requests","what":"General information","title":"Contributing to tidypolars","text":"Please create Git branch pull request (PR). tidypolars uses roxygen2, Markdown syntax, documentation. PR user-visible change, may add bullet point NEWS.md describing changes made. may optionally add GitHub username, links relevant issue(s)/PR(s).","code":""},{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":"how-to-add-support-for-an-r-function-in-tidypolars","dir":"","previous_headings":"Pull requests","what":"How to add support for an R function in tidypolars?","title":"Contributing to tidypolars","text":"use function supported, tidypolars throw error. doesn’t mean tidypolars support , simply implemented yet. tidypolars can technically support hundreds functions manipulate numbers, strings, dates, limited tidyverse. first step come across unsupported function find corresponding syntax polars. Just example, suppose stringr::str_ends() yet supported (actually ). first define simple test data.frame DataFrame counterpart polars: , find polars syntax gives output stringr::str_ends(). case, polars string methods $ends_with(): interests us expression inside $with_columns() call. Now know polars translation, let’s put function tidypolars know. Internally, tidypolars prefix function name (str_ends) pl_ look translated functions. Depending function translate, can stored different places. function works strings, can store R/funs-string.R. add support negate argument, look like: can notice new function must named pl__. multiple packages can export functions name (example data.table::() dplyr::()). Therefore, want ensure translation called function comes specific package. check_empty_dots(...) grab additional arguments stringr::str_ends() might ignore counterparts polars (also adds message warning user arguments used). package reloaded, can use function tidypolars workflow: Finally, thing left add tests tests/testthat folder.","code":"library(dplyr, warn.conflicts = FALSE) library(stringr) library(polars) test <- tibble(x = c(\"abc\", \"a1\", \"dac\")) test_pl <- pl$DataFrame(x = c(\"abc\", \"a1\", \"dac\")) test |> mutate(ends_with_c = str_ends(x, \"c\")) ## # A tibble: 3 × 2 ## x ends_with_c ## ## 1 abc TRUE ## 2 a1 FALSE ## 3 dac TRUE test_pl$with_columns( ends_with_c = pl$col(\"x\")$str$ends_with(\"c\") ) ## shape: (3, 2) ## ┌─────┬─────────────┐ ## │ x ┆ ends_with_c │ ## │ --- ┆ --- │ ## │ str ┆ bool │ ## ╞═════╪═════════════╡ ## │ abc ┆ true │ ## │ a1 ┆ false │ ## │ dac ┆ true │ ## └─────┴─────────────┘ pl_str_ends_stringr <- function(string, pattern, negate = FALSE, ...) { check_empty_dots(...) out <- string$str$ends_with(pattern) if (isTRUE(negate)) { out$not() } else { out } } library(tidypolars, warn.conflicts = FALSE) test_pl |> mutate(ends_with_c = str_ends(x, \"c\")) ## shape: (3, 2) ## ┌─────┬─────────────┐ ## │ x ┆ ends_with_c │ ## │ --- ┆ --- │ ## │ str ┆ bool │ ## ╞═════╪═════════════╡ ## │ abc ┆ true │ ## │ a1 ┆ false │ ## │ dac ┆ true │ ## └─────┴─────────────┘"},{"path":"https://tidypolars.etiennebacher.com/CONTRIBUTING.html","id":"testing-changes","dir":"","previous_headings":"Pull requests","what":"Testing changes","title":"Contributing to tidypolars","text":"tidypolars uses testthat check functions expected output. changes affect behavior functions (example adding extra argument), add tests related file tests/testthat. tidyverse functions apply entire dataframe (e.g., drop_na()) test file (test-drop_na.R case). Functions apply one multiple vectors (.e. functions used mutate(), summarize(), etc.) tested specific files. added function R/funs-string.R, add tests tests/testthat/test-funs_string.R (datetime functions, etc.). matter type function added modified, write tests Polars DataFrames. automatically modified running tests run LazyFrames well (instance, file test-drop_na-lazy.R automatically generated).","code":""},{"path":"https://tidypolars.etiennebacher.com/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 tidypolars authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/faq.html","id":"is-tidypolars-slower-than-polars","dir":"Articles","previous_headings":"","what":"Is tidypolars slower than polars?","title":"FAQ","text":", just marginally. objective tidypolars modify data, simply translate tidyverse syntax polars syntax. polars still charge data manipulations hood. Therefore, might minor overhead still need parse expressions rewrite polars syntax (see Parsing expressions vignette) marginal.","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/faq.html","id":"am-i-stuck-with-tidypolars","dir":"Articles","previous_headings":"","what":"Am I stuck with tidypolars?","title":"FAQ","text":", tidypolars always return DataFrames, LazyFrames Series. Therefore, point want use polars need control want reduce number dependencies, can easily .","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/faq.html","id":"do-i-still-need-to-load-polars","dir":"Articles","previous_headings":"","what":"Do I still need to load polars?","title":"FAQ","text":"Yes, tidypolars doesn’t provide functions create polars DataFrame LazyFrame read data. ’ll still need use polars .","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/faq.html","id":"can-i-see-some-benchmarks-with-other-tools","dir":"Articles","previous_headings":"","what":"Can I see some benchmarks with other tools?","title":"FAQ","text":"Making accurate benchmarks data wrangling tools difficult won’t try (just put one homepage give idea performance, means comprehensive). refer DuckDB benchmarks.","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"how-does-tidypolars-translate-r-expressions-into-polars-expressions","dir":"Articles","previous_headings":"","what":"How does tidypolars translate R expressions into Polars expressions?","title":"R and Polars expressions","text":"tidypolars receives expression, runs function translate() several times components translated Polars equivalent. four possible components: single values, column names, external objects, functions.","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"single-values-column-names-and-external-objects","dir":"Articles","previous_headings":"How does tidypolars translate R expressions into Polars expressions?","what":"Single values, column names, and external objects","title":"R and Polars expressions","text":"pass single value, like x = 1 x = \"\", wrapped pl$lit(). also case external objects difference need wrapped {{ }} evaluated wrapped pl$lit(). Column names, like x = mpg, wrapped pl$col().","code":"x = \"a\" -> x = pl$lit(\"a\") x = {{ some_value }} -> x = pl$lit(*value*) x = mpg -> x = pl$col(\"mpg\")"},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"functions","dir":"Articles","previous_headings":"How does tidypolars translate R expressions into Polars expressions?","what":"Functions","title":"R and Polars expressions","text":"Functions split two categories: built-functions (.e functions provided base R packages), user-defined functions (UDF) written user ().","code":""},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"built-in-functions","dir":"Articles","previous_headings":"How does tidypolars translate R expressions into Polars expressions? > Functions","what":"Built-in functions","title":"R and Polars expressions","text":"first case, tidypolars checks function name whether already translated internally. example, call R function mean(x, trim = 2), looks translation mean(). can see list supported R functions bottom vignette. Note essential base R functions supported, well many functions dplyr stringr example. Now tidypolars knows translation mean() exists, parses arguments call translate Polars syntax: internally, x converted pl$col(\"x\") column \"x\" data. Sometimes, additional arguments equivalent Polars. case argument trim . case, tidypolars ignores argument warns user: behavior can changed throw error instead.","code":"library(tidypolars) library(polars) mtcars |> as_polars_df() |> mutate(x = mean(mpg, trim = 2)) #> Warning: #> Package tidypolars doesn't know how to use some arguments of `mean()`. #> The following argument(s) will be ignored: `trim`. #> shape: (32, 12) #> ┌──────┬─────┬───────┬───────┬───┬─────┬──────┬──────┬───────────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ am ┆ gear ┆ carb ┆ x │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪══════╪══════╪═══════════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 20.090625 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 20.090625 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 1.0 ┆ 20.090625 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 1.0 ┆ 20.090625 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 2.0 ┆ 20.090625 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 2.0 ┆ 20.090625 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 4.0 ┆ 20.090625 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 6.0 ┆ 20.090625 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 8.0 ┆ 20.090625 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 2.0 ┆ 20.090625 │ #> └──────┴─────┴───────┴───────┴───┴─────┴──────┴──────┴───────────┘"},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"user-defined-functions","dir":"Articles","previous_headings":"How does tidypolars translate R expressions into Polars expressions? > Functions","what":"User-defined functions","title":"R and Polars expressions","text":"User-defined functions (UDF) challenging. Indeed, technically possible inspect code inside UDF, rewriting match Polars syntax extremely complicated. situation, rewrite custom function using Polars syntax returns Polars expression. example, make function standardize column like : Remember column name used x end wrapped pl$col(), check function returns Polars expression, provide pl$col() call: function correctly returns Polars expression, can now use like function:","code":"pl_standardize <- function(x) { (x - x$mean()) / x$std() } pl_standardize(pl$col(\"mpg\")) #> polars Expr: [([(col(\"mpg\")) - (col(\"mpg\").mean())]) // (col(\"mpg\").std())] mtcars |> as_polars_df() |> mutate(x = pl_standardize(mpg)) #> shape: (32, 12) #> ┌──────┬─────┬───────┬───────┬───┬─────┬──────┬──────┬───────────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ am ┆ gear ┆ carb ┆ x │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪══════╪══════╪═══════════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 0.150885 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 0.150885 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 1.0 ┆ 0.449543 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 1.0 ┆ 0.217253 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 2.0 ┆ -0.230735 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 2.0 ┆ 1.710547 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 4.0 ┆ -0.711907 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 6.0 ┆ -0.064813 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 8.0 ┆ -0.844644 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 2.0 ┆ 0.217253 │ #> └──────┴─────┴───────┴───────┴───┴─────┴──────┴──────┴───────────┘"},{"path":"https://tidypolars.etiennebacher.com/articles/r-and-polars-expressions.html","id":"special-case-across","dir":"Articles","previous_headings":"How does tidypolars translate R expressions into Polars expressions? > Functions","what":"Special case: across()","title":"R and Polars expressions","text":"across() useful function applies function (list functions) selection columns. accepts built-functions, UDFs, anonymous functions. Similarly, UDFs anonymous functions error don’t return Polars expression:","code":"mtcars |> as_polars_df() |> mutate( across( .cols = contains(\"a\"), list(mean = mean, stand = pl_standardize, ~ sd(.x)) ) ) #> shape: (32, 23) #> ┌──────┬─────┬───────┬───────┬───┬──────────┬───────────┬────────────┬────────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ gear_3 ┆ carb_mean ┆ carb_stand ┆ carb_3 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪══════════╪═══════════╪════════════╪════════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ 0.735203 ┆ 1.6152 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ 0.735203 ┆ 1.6152 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ -1.122152 ┆ 1.6152 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ -1.122152 ┆ 1.6152 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ -0.503034 ┆ 1.6152 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ -0.503034 ┆ 1.6152 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ 0.735203 ┆ 1.6152 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ 1.97344 ┆ 1.6152 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ 3.211677 ┆ 1.6152 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 0.737804 ┆ 2.8125 ┆ -0.503034 ┆ 1.6152 │ #> └──────┴─────┴───────┴───────┴───┴──────────┴───────────┴────────────┴────────┘ mtcars |> as_polars_df() |> mutate( across( .cols = contains(\"a\"), .fns = list( mean = mean, function(x) { (x - mean(x)) / sd(x) }, ~ sd(.x) ) ) ) #> Error in `mutate()`: #> ! Could not evaluate an anonymous function in `across()`. #> ℹ Are you sure the anonymous function returns a Polars expression?"},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Etienne Bacher. Author, maintainer, copyright holder.","code":""},{"path":"https://tidypolars.etiennebacher.com/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Bacher E (2024). tidypolars: Get Power Polars Syntax Tidyverse. R package version 0.12.0.9000, https://etiennebacher.r-universe.dev/tidypolars, https://tidypolars.etiennebacher.com.","code":"@Manual{, title = {tidypolars: Get the Power of Polars with the Syntax of the Tidyverse}, author = {Etienne Bacher}, year = {2024}, note = {R package version 0.12.0.9000, https://etiennebacher.r-universe.dev/tidypolars}, url = {https://tidypolars.etiennebacher.com}, }"},{"path":"https://tidypolars.etiennebacher.com/index.html","id":"tidypolars-","dir":"","previous_headings":"","what":"Get the Power of Polars with the Syntax of the Tidyverse","title":"Get the Power of Polars with the Syntax of the Tidyverse","text":"ℹ️ R package “tidypolars”. Python one : markfairbanks/tidypolars","code":""},{"path":"https://tidypolars.etiennebacher.com/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"Get the Power of Polars with the Syntax of the Tidyverse","text":"tidypolars provides polars backend tidyverse. aim tidypolars enable users keep existing tidyverse code using polars background benefit large performance gains. thing needs change way data imported R session. See “Getting started” vignette gentle introduction tidypolars. Since work rewriting tidyverse code polars syntax, tidypolars polars similar performance. main purpose benchmark show polars tidypolars close give idea performance. thorough, representative benchmarks polars, take look DuckDB benchmarks instead.","code":"library(collapse, warn.conflicts = FALSE) #> collapse 2.0.16, see ?`collapse-package` or ?`collapse-documentation` library(dplyr, warn.conflicts = FALSE) library(dtplyr) library(polars) library(tidypolars) large_iris <- data.table::rbindlist(rep(list(iris), 100000)) large_iris_pl <- as_polars_lf(large_iris) large_iris_dt <- lazy_dt(large_iris) format(nrow(large_iris), big.mark = \",\") #> [1] \"15,000,000\" bench::mark( polars = { large_iris_pl$ select(c(\"Sepal.Length\", \"Sepal.Width\", \"Petal.Length\", \"Petal.Width\"))$ with_columns( pl$when( (pl$col(\"Petal.Length\") / pl$col(\"Petal.Width\") > 3) )$then(pl$lit(\"long\"))$ otherwise(pl$lit(\"large\"))$ alias(\"petal_type\") )$ filter(pl$col(\"Sepal.Length\")$is_between(4.5, 5.5))$ collect() }, tidypolars = { large_iris_pl |> select(starts_with(c(\"Sep\", \"Pet\"))) |> mutate( petal_type = ifelse((Petal.Length / Petal.Width) > 3, \"long\", \"large\") ) |> filter(between(Sepal.Length, 4.5, 5.5)) |> compute() }, dplyr = { large_iris |> select(starts_with(c(\"Sep\", \"Pet\"))) |> mutate( petal_type = ifelse((Petal.Length / Petal.Width) > 3, \"long\", \"large\") ) |> filter(between(Sepal.Length, 4.5, 5.5)) }, dtplyr = { large_iris_dt |> select(starts_with(c(\"Sep\", \"Pet\"))) |> mutate( petal_type = ifelse((Petal.Length / Petal.Width) > 3, \"long\", \"large\") ) |> filter(between(Sepal.Length, 4.5, 5.5)) |> as.data.frame() }, collapse = { large_iris |> fselect(c(\"Sepal.Length\", \"Sepal.Width\", \"Petal.Length\", \"Petal.Width\")) |> fmutate( petal_type = data.table::fifelse((Petal.Length / Petal.Width) > 3, \"long\", \"large\") ) |> fsubset(Sepal.Length >= 4.5 & Sepal.Length <= 5.5) }, check = FALSE, iterations = 40 ) #> Warning: Some expressions had a GC in every iteration; #> so filtering is disabled. #> # A tibble: 5 × 6 #> expression min median `itr/sec` mem_alloc #> #> 1 polars 277.93ms 304.59ms 3.17 1.99MB #> 2 tidypolars 286.78ms 362.65ms 2.35 1.2MB #> 3 dplyr 3.16s 3.63s 0.257 1.79GB #> 4 dtplyr 1.58s 1.92s 0.461 1.72GB #> 5 collapse 702.79ms 948.19ms 0.987 745.96MB #> # ℹ 1 more variable: `gc/sec` # NOTE: do NOT take the \"mem_alloc\" results into account. # `bench::mark()` doesn't report the accurate memory usage for packages calling # Rust code."},{"path":"https://tidypolars.etiennebacher.com/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Get the Power of Polars with the Syntax of the Tidyverse","text":"tidypolars built polars, available CRAN. means tidypolars also can’t CRAN. However, can install R-universe.","code":"Sys.setenv(NOT_CRAN = \"true\") install.packages(\"tidypolars\", repos = c(\"https://community.r-multiverse.org\", 'https://cloud.r-project.org'))"},{"path":"https://tidypolars.etiennebacher.com/index.html","id":"contributing","dir":"","previous_headings":"","what":"Contributing","title":"Get the Power of Polars with the Syntax of the Tidyverse","text":"find bugs errors documentation? want tidypolars support functions? Take look contributing guide instructions bug report pull requests.","code":""},{"path":"https://tidypolars.etiennebacher.com/index.html","id":"acknowledgements","dir":"","previous_headings":"","what":"Acknowledgements","title":"Get the Power of Polars with the Syntax of the Tidyverse","text":"website theme heavily inspired Matthew Kay’s ggblend package: https://mjskay.github.io/ggblend/. package hex logo created Hubert Hałun part Appsilon Hex Contest.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/arrange.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Order rows using column values — arrange.RPolarsDataFrame","title":"Order rows using column values — arrange.RPolarsDataFrame","text":"Order rows using column values","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/arrange.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Order rows using column values — arrange.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' arrange(.data, ..., .by_group = FALSE)"},{"path":"https://tidypolars.etiennebacher.com/reference/arrange.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Order rows using column values — arrange.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Variables, functions variables. Use desc() sort variable descending order. .by_group TRUE, sort data within groups.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/arrange.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Order rows using column values — arrange.RPolarsDataFrame","text":"","code":"pl_test <- polars::pl$DataFrame( x1 = c(\"a\", \"a\", \"b\", \"a\", \"c\"), x2 = c(2, 1, 5, 3, 1), value = sample(1:5) ) arrange(pl_test, x1) #> shape: (5, 3) #> ┌─────┬─────┬───────┐ #> │ x1 ┆ x2 ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ i32 │ #> ╞═════╪═════╪═══════╡ #> │ a ┆ 2.0 ┆ 5 │ #> │ a ┆ 1.0 ┆ 3 │ #> │ a ┆ 3.0 ┆ 1 │ #> │ b ┆ 5.0 ┆ 4 │ #> │ c ┆ 1.0 ┆ 2 │ #> └─────┴─────┴───────┘ arrange(pl_test, x1, -x2) #> shape: (5, 3) #> ┌─────┬─────┬───────┐ #> │ x1 ┆ x2 ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ i32 │ #> ╞═════╪═════╪═══════╡ #> │ a ┆ 3.0 ┆ 1 │ #> │ a ┆ 2.0 ┆ 5 │ #> │ a ┆ 1.0 ┆ 3 │ #> │ b ┆ 5.0 ┆ 4 │ #> │ c ┆ 1.0 ┆ 2 │ #> └─────┴─────┴───────┘ # if the data is grouped, you need to specify `.by_group = TRUE` to sort by # the groups first pl_test |> group_by(x1) |> arrange(-x2, .by_group = TRUE) #> shape: (5, 3) #> ┌─────┬─────┬───────┐ #> │ x1 ┆ x2 ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ i32 │ #> ╞═════╪═════╪═══════╡ #> │ a ┆ 3.0 ┆ 1 │ #> │ a ┆ 2.0 ┆ 5 │ #> │ a ┆ 1.0 ┆ 3 │ #> │ b ┆ 5.0 ┆ 4 │ #> │ c ┆ 1.0 ┆ 2 │ #> └─────┴─────┴───────┘ #> Groups [3]: x1 #> Maintain order: FALSE"},{"path":"https://tidypolars.etiennebacher.com/reference/as_tibble.tidypolars.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","title":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","text":"makes easier convert polars DataFrame LazyFrame tibble pipe workflow.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/as_tibble.tidypolars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","text":"","code":"# S3 method for class 'tidypolars' as_tibble(x, int64_conversion = polars::polars_options()$int64_conversion, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/as_tibble.tidypolars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","text":"x Polars Data/LazyFrame int64_conversion Int64 values handled converting polars object R? See documentation polars::.data.frame.RPolarsDataFrame. ... Options passed polars::.data.frame.RPolarsDataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/as_tibble.tidypolars.html","id":"about-int-","dir":"Reference","previous_headings":"","what":"About int64","title":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","text":"Int64 format accepted Polars natively R (package bit64 helps ). Since tidypolars simply wrapper around polars, behavior int64 values depend options set polars. Use options(polars.int64_conversion =) specify int64 variables handled. See documentation polars possible options.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/as_tibble.tidypolars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert a Polars DataFrame to an R data.frame or to a tibble — as_tibble.tidypolars","text":"","code":"iris |> as_polars_df() |> filter(Sepal.Length > 6) |> as_tibble() #> # A tibble: 61 × 5 #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> #> 1 7 3.2 4.7 1.4 versicolor #> 2 6.4 3.2 4.5 1.5 versicolor #> 3 6.9 3.1 4.9 1.5 versicolor #> 4 6.5 2.8 4.6 1.5 versicolor #> 5 6.3 3.3 4.7 1.6 versicolor #> 6 6.6 2.9 4.6 1.3 versicolor #> 7 6.1 2.9 4.7 1.4 versicolor #> 8 6.7 3.1 4.4 1.4 versicolor #> 9 6.2 2.2 4.5 1.5 versicolor #> 10 6.1 2.8 4 1.3 versicolor #> # ℹ 51 more rows"},{"path":"https://tidypolars.etiennebacher.com/reference/bind_cols_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Append multiple Data/LazyFrames next to each other — bind_cols_polars","title":"Append multiple Data/LazyFrames next to each other — bind_cols_polars","text":"Append multiple Data/LazyFrames next ","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/bind_cols_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Append multiple Data/LazyFrames next to each other — bind_cols_polars","text":"","code":"bind_cols_polars(..., .name_repair = \"unique\")"},{"path":"https://tidypolars.etiennebacher.com/reference/bind_cols_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Append multiple Data/LazyFrames next to each other — bind_cols_polars","text":"... Polars DataFrames LazyFrames combine. argument can either Data/LazyFrame, list Data/LazyFrames. Columns matched name. Data/LazyFrames must number rows duplicated column names. .name_repair Can \"unique\", \"universal\", \"check_unique\", \"minimal\". See vctrs::vec_as_names() explanations value.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/bind_cols_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Append multiple Data/LazyFrames next to each other — bind_cols_polars","text":"","code":"p1 <- polars::pl$DataFrame( x = sample(letters, 20), y = sample(1:100, 20) ) p2 <- polars::pl$DataFrame( z = sample(letters, 20), w = sample(1:100, 20) ) bind_cols_polars(p1, p2) #> shape: (20, 4) #> ┌─────┬─────┬─────┬─────┐ #> │ x ┆ y ┆ z ┆ w │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ str ┆ i32 │ #> ╞═════╪═════╪═════╪═════╡ #> │ o ┆ 4 ┆ f ┆ 3 │ #> │ z ┆ 34 ┆ b ┆ 38 │ #> │ d ┆ 35 ┆ s ┆ 68 │ #> │ f ┆ 89 ┆ n ┆ 65 │ #> │ i ┆ 86 ┆ a ┆ 6 │ #> │ … ┆ … ┆ … ┆ … │ #> │ l ┆ 17 ┆ k ┆ 41 │ #> │ q ┆ 52 ┆ j ┆ 42 │ #> │ w ┆ 56 ┆ w ┆ 66 │ #> │ s ┆ 97 ┆ y ┆ 26 │ #> │ h ┆ 1 ┆ g ┆ 60 │ #> └─────┴─────┴─────┴─────┘ bind_cols_polars(list(p1, p2)) #> shape: (20, 4) #> ┌─────┬─────┬─────┬─────┐ #> │ x ┆ y ┆ z ┆ w │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ str ┆ i32 │ #> ╞═════╪═════╪═════╪═════╡ #> │ o ┆ 4 ┆ f ┆ 3 │ #> │ z ┆ 34 ┆ b ┆ 38 │ #> │ d ┆ 35 ┆ s ┆ 68 │ #> │ f ┆ 89 ┆ n ┆ 65 │ #> │ i ┆ 86 ┆ a ┆ 6 │ #> │ … ┆ … ┆ … ┆ … │ #> │ l ┆ 17 ┆ k ┆ 41 │ #> │ q ┆ 52 ┆ j ┆ 42 │ #> │ w ┆ 56 ┆ w ┆ 66 │ #> │ s ┆ 97 ┆ y ┆ 26 │ #> │ h ┆ 1 ┆ g ┆ 60 │ #> └─────┴─────┴─────┴─────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/bind_rows_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Stack multiple Data/LazyFrames on top of each other — bind_rows_polars","title":"Stack multiple Data/LazyFrames on top of each other — bind_rows_polars","text":"Stack multiple Data/LazyFrames top ","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/bind_rows_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stack multiple Data/LazyFrames on top of each other — bind_rows_polars","text":"","code":"bind_rows_polars(..., .id = NULL)"},{"path":"https://tidypolars.etiennebacher.com/reference/bind_rows_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stack multiple Data/LazyFrames on top of each other — bind_rows_polars","text":"... Polars DataFrames LazyFrames combine. argument can either Data/LazyFrame, list Data/LazyFrames. Columns matched name, missing columns filled NA. .id name optional identifier column. Provide string create output column identifies input. elements ... named, identifier use names. Otherwise, simple count.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/bind_rows_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Stack multiple Data/LazyFrames on top of each other — bind_rows_polars","text":"","code":"library(polars) p1 <- pl$DataFrame( x = c(\"a\", \"b\"), y = 1:2 ) p2 <- pl$DataFrame( y = 3:4, z = c(\"c\", \"d\") )$with_columns(pl$col(\"y\")$cast(pl$Int16)) bind_rows_polars(p1, p2) #> shape: (4, 3) #> ┌──────┬─────┬──────┐ #> │ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ str │ #> ╞══════╪═════╪══════╡ #> │ a ┆ 1 ┆ null │ #> │ b ┆ 2 ┆ null │ #> │ null ┆ 3 ┆ c │ #> │ null ┆ 4 ┆ d │ #> └──────┴─────┴──────┘ # this is equivalent bind_rows_polars(list(p1, p2)) #> shape: (4, 3) #> ┌──────┬─────┬──────┐ #> │ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ str │ #> ╞══════╪═════╪══════╡ #> │ a ┆ 1 ┆ null │ #> │ b ┆ 2 ┆ null │ #> │ null ┆ 3 ┆ c │ #> │ null ┆ 4 ┆ d │ #> └──────┴─────┴──────┘ # create an id colum bind_rows_polars(p1, p2, .id = \"id\") #> shape: (4, 4) #> ┌─────┬──────┬─────┬──────┐ #> │ id ┆ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ i32 ┆ str │ #> ╞═════╪══════╪═════╪══════╡ #> │ 1 ┆ a ┆ 1 ┆ null │ #> │ 1 ┆ b ┆ 2 ┆ null │ #> │ 2 ┆ null ┆ 3 ┆ c │ #> │ 2 ┆ null ┆ 4 ┆ d │ #> └─────┴──────┴─────┴──────┘ # create an id colum with named elements bind_rows_polars(p1 = p1, p2 = p2, .id = \"id\") #> shape: (4, 4) #> ┌─────┬──────┬─────┬──────┐ #> │ id ┆ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ i32 ┆ str │ #> ╞═════╪══════╪═════╪══════╡ #> │ p1 ┆ a ┆ 1 ┆ null │ #> │ p1 ┆ b ┆ 2 ┆ null │ #> │ p2 ┆ null ┆ 3 ┆ c │ #> │ p2 ┆ null ┆ 4 ┆ d │ #> └─────┴──────┴─────┴──────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/complete.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Complete a data frame with missing combinations of data — complete.RPolarsDataFrame","title":"Complete a data frame with missing combinations of data — complete.RPolarsDataFrame","text":"Turns implicit missing values explicit missing values. useful completing missing combinations data.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/complete.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Complete a data frame with missing combinations of data — complete.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' complete(data, ..., fill = list()) # S3 method for class 'RPolarsLazyFrame' complete(data, ..., fill = list())"},{"path":"https://tidypolars.etiennebacher.com/reference/complete.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Complete a data frame with missing combinations of data — complete.RPolarsDataFrame","text":"data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. fill named list variable supplies single value use instead NA missing combinations.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/complete.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Complete a data frame with missing combinations of data — complete.RPolarsDataFrame","text":"","code":"df <- polars::pl$DataFrame( group = c(1:2, 1, 2), item_id = c(1:2, 2, 3), item_name = c(\"a\", \"a\", \"b\", \"b\"), value1 = c(1, NA, 3, 4), value2 = 4:7 ) df #> shape: (4, 5) #> ┌───────┬─────────┬───────────┬────────┬────────┐ #> │ group ┆ item_id ┆ item_name ┆ value1 ┆ value2 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ str ┆ f64 ┆ i32 │ #> ╞═══════╪═════════╪═══════════╪════════╪════════╡ #> │ 1.0 ┆ 1.0 ┆ a ┆ 1.0 ┆ 4 │ #> │ 2.0 ┆ 2.0 ┆ a ┆ null ┆ 5 │ #> │ 1.0 ┆ 2.0 ┆ b ┆ 3.0 ┆ 6 │ #> │ 2.0 ┆ 3.0 ┆ b ┆ 4.0 ┆ 7 │ #> └───────┴─────────┴───────────┴────────┴────────┘ df |> complete(group, item_id, item_name) #> shape: (12, 5) #> ┌───────┬─────────┬───────────┬────────┬────────┐ #> │ group ┆ item_id ┆ item_name ┆ value1 ┆ value2 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ str ┆ f64 ┆ i32 │ #> ╞═══════╪═════════╪═══════════╪════════╪════════╡ #> │ 1.0 ┆ 1.0 ┆ a ┆ 1.0 ┆ 4 │ #> │ 1.0 ┆ 1.0 ┆ b ┆ null ┆ null │ #> │ 1.0 ┆ 2.0 ┆ a ┆ null ┆ null │ #> │ 1.0 ┆ 2.0 ┆ b ┆ 3.0 ┆ 6 │ #> │ 1.0 ┆ 3.0 ┆ a ┆ null ┆ null │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 2.0 ┆ 1.0 ┆ b ┆ null ┆ null │ #> │ 2.0 ┆ 2.0 ┆ a ┆ null ┆ 5 │ #> │ 2.0 ┆ 2.0 ┆ b ┆ null ┆ null │ #> │ 2.0 ┆ 3.0 ┆ a ┆ null ┆ null │ #> │ 2.0 ┆ 3.0 ┆ b ┆ 4.0 ┆ 7 │ #> └───────┴─────────┴───────────┴────────┴────────┘ df |> complete( group, item_id, item_name, fill = list(value1 = 0, value2 = 99) ) #> shape: (12, 5) #> ┌───────┬─────────┬───────────┬────────┬────────┐ #> │ group ┆ item_id ┆ item_name ┆ value1 ┆ value2 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ str ┆ f64 ┆ f64 │ #> ╞═══════╪═════════╪═══════════╪════════╪════════╡ #> │ 1.0 ┆ 1.0 ┆ a ┆ 1.0 ┆ 4.0 │ #> │ 1.0 ┆ 1.0 ┆ b ┆ 0.0 ┆ 99.0 │ #> │ 1.0 ┆ 2.0 ┆ a ┆ 0.0 ┆ 99.0 │ #> │ 1.0 ┆ 2.0 ┆ b ┆ 3.0 ┆ 6.0 │ #> │ 1.0 ┆ 3.0 ┆ a ┆ 0.0 ┆ 99.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 2.0 ┆ 1.0 ┆ b ┆ 0.0 ┆ 99.0 │ #> │ 2.0 ┆ 2.0 ┆ a ┆ 0.0 ┆ 5.0 │ #> │ 2.0 ┆ 2.0 ┆ b ┆ 0.0 ┆ 99.0 │ #> │ 2.0 ┆ 3.0 ┆ a ┆ 0.0 ┆ 99.0 │ #> │ 2.0 ┆ 3.0 ┆ b ┆ 4.0 ┆ 7.0 │ #> └───────┴─────────┴───────────┴────────┴────────┘ df |> group_by(group, maintain_order = TRUE) |> complete(item_id, item_name) #> shape: (8, 5) #> ┌───────┬─────────┬───────────┬────────┬────────┐ #> │ group ┆ item_id ┆ item_name ┆ value1 ┆ value2 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ str ┆ f64 ┆ i32 │ #> ╞═══════╪═════════╪═══════════╪════════╪════════╡ #> │ 1.0 ┆ 1.0 ┆ a ┆ 1.0 ┆ 4 │ #> │ 1.0 ┆ 1.0 ┆ b ┆ null ┆ null │ #> │ 1.0 ┆ 2.0 ┆ a ┆ null ┆ null │ #> │ 1.0 ┆ 2.0 ┆ b ┆ 3.0 ┆ 6 │ #> │ 2.0 ┆ 2.0 ┆ a ┆ null ┆ 5 │ #> │ 2.0 ┆ 2.0 ┆ b ┆ null ┆ null │ #> │ 2.0 ┆ 3.0 ┆ a ┆ null ┆ null │ #> │ 2.0 ┆ 3.0 ┆ b ┆ 4.0 ┆ 7 │ #> └───────┴─────────┴───────────┴────────┴────────┘ #> Groups [2]: group #> Maintain order: TRUE"},{"path":"https://tidypolars.etiennebacher.com/reference/compute.RPolarsLazyFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Collect a LazyFrame — compute.RPolarsLazyFrame","title":"Collect a LazyFrame — compute.RPolarsLazyFrame","text":"compute() checks query, optimizes background, runs . output Polars DataFrame. collect() similar compute() converts output R data.frame, consumes memory. tidypolars 0.7.0, collect() used collect LazyFrame Polars DataFrame. usage still valid now change 0.8.0 automatically convert DataFrame data.frame. Use compute() Polars DataFrame output.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/compute.RPolarsLazyFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collect a LazyFrame — compute.RPolarsLazyFrame","text":"","code":"# S3 method for class 'RPolarsLazyFrame' compute( x, ..., type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, comm_subplan_elim = TRUE, comm_subexpr_elim = TRUE, cluster_with_columns = TRUE, no_optimization = FALSE, streaming = FALSE, collect_in_background = FALSE ) # S3 method for class 'RPolarsLazyFrame' collect( x, ..., type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, comm_subplan_elim = TRUE, comm_subexpr_elim = TRUE, cluster_with_columns = TRUE, no_optimization = FALSE, streaming = FALSE, collect_in_background = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/compute.RPolarsLazyFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collect a LazyFrame — compute.RPolarsLazyFrame","text":"x Polars LazyFrame ... Dots empty. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). comm_subplan_elim Cache branching subplans occur self-joins unions (default TRUE). comm_subexpr_elim Cache common subexpressions (default TRUE). cluster_with_columns Combine sequential independent calls $with_columns(). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE. streaming Run parts query streaming fashion (alpha state). Default FALSE. collect_in_background Detach query R session. Computation start background. Get handle later can converted resulting DataFrame. Useful interactive mode lock R session (default FALSE).","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/reference/compute.RPolarsLazyFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collect a LazyFrame — compute.RPolarsLazyFrame","text":"","code":"dat_lazy <- polars::as_polars_df(iris)$lazy() compute(dat_lazy) #> shape: (150, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ # you can build a query and add compute() as the last piece dat_lazy |> select(starts_with(\"Sepal\")) |> filter(between(Sepal.Length, 5, 6)) |> compute() #> shape: (67, 2) #> ┌──────────────┬─────────────┐ #> │ Sepal.Length ┆ Sepal.Width │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════════════╪═════════════╡ #> │ 5.1 ┆ 3.5 │ #> │ 5.0 ┆ 3.6 │ #> │ 5.4 ┆ 3.9 │ #> │ 5.0 ┆ 3.4 │ #> │ 5.4 ┆ 3.7 │ #> │ … ┆ … │ #> │ 6.0 ┆ 2.2 │ #> │ 5.6 ┆ 2.8 │ #> │ 6.0 ┆ 3.0 │ #> │ 5.8 ┆ 2.7 │ #> │ 5.9 ┆ 3.0 │ #> └──────────────┴─────────────┘ # call collect() instead to return a data.frame (note that this is more # expensive than compute()) dat_lazy |> select(starts_with(\"Sepal\")) |> filter(between(Sepal.Length, 5, 6)) |> collect() #> Sepal.Length Sepal.Width #> 1 5.1 3.5 #> 2 5.0 3.6 #> 3 5.4 3.9 #> 4 5.0 3.4 #> 5 5.4 3.7 #> 6 5.8 4.0 #> 7 5.7 4.4 #> 8 5.4 3.9 #> 9 5.1 3.5 #> 10 5.7 3.8 #> 11 5.1 3.8 #> 12 5.4 3.4 #> 13 5.1 3.7 #> 14 5.1 3.3 #> 15 5.0 3.0 #> 16 5.0 3.4 #> 17 5.2 3.5 #> 18 5.2 3.4 #> 19 5.4 3.4 #> 20 5.2 4.1 #> 21 5.5 4.2 #> 22 5.0 3.2 #> 23 5.5 3.5 #> 24 5.1 3.4 #> 25 5.0 3.5 #> 26 5.0 3.5 #> 27 5.1 3.8 #> 28 5.1 3.8 #> 29 5.3 3.7 #> 30 5.0 3.3 #> 31 5.5 2.3 #> 32 5.7 2.8 #> 33 5.2 2.7 #> 34 5.0 2.0 #> 35 5.9 3.0 #> 36 6.0 2.2 #> 37 5.6 2.9 #> 38 5.6 3.0 #> 39 5.8 2.7 #> 40 5.6 2.5 #> 41 5.9 3.2 #> 42 6.0 2.9 #> 43 5.7 2.6 #> 44 5.5 2.4 #> 45 5.5 2.4 #> 46 5.8 2.7 #> 47 6.0 2.7 #> 48 5.4 3.0 #> 49 6.0 3.4 #> 50 5.6 3.0 #> 51 5.5 2.5 #> 52 5.5 2.6 #> 53 5.8 2.6 #> 54 5.0 2.3 #> 55 5.6 2.7 #> 56 5.7 3.0 #> 57 5.7 2.9 #> 58 5.1 2.5 #> 59 5.7 2.8 #> 60 5.8 2.7 #> 61 5.7 2.5 #> 62 5.8 2.8 #> 63 6.0 2.2 #> 64 5.6 2.8 #> 65 6.0 3.0 #> 66 5.8 2.7 #> 67 5.9 3.0"},{"path":"https://tidypolars.etiennebacher.com/reference/count.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Count the observations in each group — count.RPolarsDataFrame","title":"Count the observations in each group — count.RPolarsDataFrame","text":"Count observations group","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/count.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count the observations in each group — count.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' count(x, ..., sort = FALSE, name = \"n\") # S3 method for class 'RPolarsLazyFrame' count(x, ..., sort = FALSE, name = \"n\") # S3 method for class 'RPolarsDataFrame' add_count(x, ..., sort = FALSE, name = \"n\") # S3 method for class 'RPolarsLazyFrame' add_count(x, ..., sort = FALSE, name = \"n\")"},{"path":"https://tidypolars.etiennebacher.com/reference/count.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count the observations in each group — count.RPolarsDataFrame","text":"x Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. sort TRUE, show largest groups top. name Name new column.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/count.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count the observations in each group — count.RPolarsDataFrame","text":"","code":"test <- polars::as_polars_df(mtcars) count(test, cyl) #> shape: (3, 2) #> ┌─────┬─────┐ #> │ cyl ┆ n │ #> │ --- ┆ --- │ #> │ f64 ┆ u32 │ #> ╞═════╪═════╡ #> │ 4.0 ┆ 11 │ #> │ 6.0 ┆ 7 │ #> │ 8.0 ┆ 14 │ #> └─────┴─────┘ count(test, cyl, am) #> shape: (6, 3) #> ┌─────┬─────┬─────┐ #> │ cyl ┆ am ┆ n │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ u32 │ #> ╞═════╪═════╪═════╡ #> │ 4.0 ┆ 0.0 ┆ 3 │ #> │ 4.0 ┆ 1.0 ┆ 8 │ #> │ 6.0 ┆ 0.0 ┆ 4 │ #> │ 6.0 ┆ 1.0 ┆ 3 │ #> │ 8.0 ┆ 0.0 ┆ 12 │ #> │ 8.0 ┆ 1.0 ┆ 2 │ #> └─────┴─────┴─────┘ count(test, cyl, am, sort = TRUE, name = \"count\") #> shape: (6, 3) #> ┌─────┬─────┬───────┐ #> │ cyl ┆ am ┆ count │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ u32 │ #> ╞═════╪═════╪═══════╡ #> │ 8.0 ┆ 0.0 ┆ 12 │ #> │ 4.0 ┆ 1.0 ┆ 8 │ #> │ 6.0 ┆ 0.0 ┆ 4 │ #> │ 4.0 ┆ 0.0 ┆ 3 │ #> │ 6.0 ┆ 1.0 ┆ 3 │ #> │ 8.0 ┆ 1.0 ┆ 2 │ #> └─────┴─────┴───────┘ add_count(test, cyl, am, sort = TRUE, name = \"count\") #> shape: (32, 12) #> ┌──────┬─────┬───────┬───────┬───┬─────┬──────┬──────┬───────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ am ┆ gear ┆ carb ┆ count │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ u32 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪══════╪══════╪═══════╡ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 2.0 ┆ 12 │ #> │ 14.3 ┆ 8.0 ┆ 360.0 ┆ 245.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 4.0 ┆ 12 │ #> │ 16.4 ┆ 8.0 ┆ 275.8 ┆ 180.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 3.0 ┆ 12 │ #> │ 17.3 ┆ 8.0 ┆ 275.8 ┆ 180.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 3.0 ┆ 12 │ #> │ 15.2 ┆ 8.0 ┆ 275.8 ┆ 180.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 3.0 ┆ 12 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 22.8 ┆ 4.0 ┆ 140.8 ┆ 95.0 ┆ … ┆ 0.0 ┆ 4.0 ┆ 2.0 ┆ 3 │ #> │ 21.5 ┆ 4.0 ┆ 120.1 ┆ 97.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 1.0 ┆ 3 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 6.0 ┆ 3 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 4.0 ┆ 2 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 8.0 ┆ 2 │ #> └──────┴─────┴───────┴───────┴───┴─────┴──────┴──────┴───────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/cross_join.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Cross join — cross_join.RPolarsDataFrame","title":"Cross join — cross_join.RPolarsDataFrame","text":"Cross joins match row x every row y, resulting dataset nrow(x) * nrow(y) rows.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/cross_join.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cross join — cross_join.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' cross_join(x, y, ..., suffix = c(\".x\", \".y\")) # S3 method for class 'RPolarsLazyFrame' cross_join(x, y, ..., suffix = c(\".x\", \".y\"))"},{"path":"https://tidypolars.etiennebacher.com/reference/cross_join.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cross join — cross_join.RPolarsDataFrame","text":"x, y Two Polars Data/LazyFrames ... Dots empty. suffix non-joined duplicate variables x y, suffixes added output disambiguate . character vector length 2.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/cross_join.RPolarsDataFrame.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Cross join — cross_join.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/cross_join.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cross join — cross_join.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame( origin = c(\"ALG\", \"FRA\", \"GER\"), year = c(2020, 2020, 2021) ) test2 <- polars::pl$DataFrame( destination = c(\"USA\", \"JPN\", \"BRA\"), language = c(\"english\", \"japanese\", \"portuguese\") ) test #> shape: (3, 2) #> ┌────────┬────────┐ #> │ origin ┆ year │ #> │ --- ┆ --- │ #> │ str ┆ f64 │ #> ╞════════╪════════╡ #> │ ALG ┆ 2020.0 │ #> │ FRA ┆ 2020.0 │ #> │ GER ┆ 2021.0 │ #> └────────┴────────┘ test2 #> shape: (3, 2) #> ┌─────────────┬────────────┐ #> │ destination ┆ language │ #> │ --- ┆ --- │ #> │ str ┆ str │ #> ╞═════════════╪════════════╡ #> │ USA ┆ english │ #> │ JPN ┆ japanese │ #> │ BRA ┆ portuguese │ #> └─────────────┴────────────┘ cross_join(test, test2) #> shape: (9, 4) #> ┌────────┬────────┬─────────────┬────────────┐ #> │ origin ┆ year ┆ destination ┆ language │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ str ┆ str │ #> ╞════════╪════════╪═════════════╪════════════╡ #> │ ALG ┆ 2020.0 ┆ USA ┆ english │ #> │ ALG ┆ 2020.0 ┆ JPN ┆ japanese │ #> │ ALG ┆ 2020.0 ┆ BRA ┆ portuguese │ #> │ FRA ┆ 2020.0 ┆ USA ┆ english │ #> │ FRA ┆ 2020.0 ┆ JPN ┆ japanese │ #> │ FRA ┆ 2020.0 ┆ BRA ┆ portuguese │ #> │ GER ┆ 2021.0 ┆ USA ┆ english │ #> │ GER ┆ 2021.0 ┆ JPN ┆ japanese │ #> │ GER ┆ 2021.0 ┆ BRA ┆ portuguese │ #> └────────┴────────┴─────────────┴────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/describe.html","id":null,"dir":"Reference","previous_headings":"","what":"Summary statistics for a Polars DataFrame — describe","title":"Summary statistics for a Polars DataFrame — describe","text":"function deprecated tidypolars 0.10.0, removed future update. Use summary() arguments instead.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/describe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summary statistics for a Polars DataFrame — describe","text":"","code":"describe(.data, percentiles = c(0.25, 0.75))"},{"path":"https://tidypolars.etiennebacher.com/reference/describe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summary statistics for a Polars DataFrame — describe","text":".data Polars DataFrame. percentiles One percentiles include summary statistics. values must 0 1 (NULL ignored).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/describe_plan.html","id":null,"dir":"Reference","previous_headings":"","what":"Show the optimized and non-optimized query plans — describe_plan","title":"Show the optimized and non-optimized query plans — describe_plan","text":"functions deprecated tidypolars 0.10.0, removed future update. Use explain() optimized = FALSE recover output describe_plan(), optimized = TRUE (default) get output describe_optimized_plan().","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/describe_plan.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Show the optimized and non-optimized query plans — describe_plan","text":"","code":"describe_plan(.data) describe_optimized_plan(.data)"},{"path":"https://tidypolars.etiennebacher.com/reference/describe_plan.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Show the optimized and non-optimized query plans — describe_plan","text":".data Polars LazyFrame","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/distinct.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Remove or keep only duplicated rows in a Data/LazyFrame — distinct.RPolarsDataFrame","title":"Remove or keep only duplicated rows in a Data/LazyFrame — distinct.RPolarsDataFrame","text":"default, duplicates looked variables. possible specify subset variables duplicates looked . also possible keep either first occurrence, last occurence remove duplicates.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/distinct.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Remove or keep only duplicated rows in a Data/LazyFrame — distinct.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' distinct(.data, ..., keep = \"first\", maintain_order = TRUE) # S3 method for class 'RPolarsLazyFrame' distinct(.data, ..., keep = \"first\", maintain_order = TRUE) duplicated_rows(.data, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/distinct.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Remove or keep only duplicated rows in a Data/LazyFrame — distinct.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. keep Either \"first\" (keep first occurrence duplicated row), \"last\" (last occurrence) \"none\" (remove ofccurences duplicated rows). maintain_order Maintain row order. default can slow process large datasets prevents use streaming.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/distinct.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Remove or keep only duplicated rows in a Data/LazyFrame — distinct.RPolarsDataFrame","text":"","code":"pl_test <- polars::pl$DataFrame( iso_o = c(rep(c(\"AA\", \"AB\"), each = 2), \"AC\", \"DC\"), iso_d = rep(c(\"BA\", \"BB\", \"BC\"), each = 2), value = c(2, 2, 3, 4, 5, 6) ) distinct(pl_test) #> shape: (5, 3) #> ┌───────┬───────┬───────┐ #> │ iso_o ┆ iso_d ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ f64 │ #> ╞═══════╪═══════╪═══════╡ #> │ AA ┆ BA ┆ 2.0 │ #> │ AB ┆ BB ┆ 3.0 │ #> │ AB ┆ BB ┆ 4.0 │ #> │ AC ┆ BC ┆ 5.0 │ #> │ DC ┆ BC ┆ 6.0 │ #> └───────┴───────┴───────┘ distinct(pl_test, iso_o) #> shape: (4, 3) #> ┌───────┬───────┬───────┐ #> │ iso_o ┆ iso_d ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ f64 │ #> ╞═══════╪═══════╪═══════╡ #> │ AA ┆ BA ┆ 2.0 │ #> │ AB ┆ BB ┆ 3.0 │ #> │ AC ┆ BC ┆ 5.0 │ #> │ DC ┆ BC ┆ 6.0 │ #> └───────┴───────┴───────┘ duplicated_rows(pl_test) #> shape: (2, 3) #> ┌───────┬───────┬───────┐ #> │ iso_o ┆ iso_d ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ f64 │ #> ╞═══════╪═══════╪═══════╡ #> │ AA ┆ BA ┆ 2.0 │ #> │ AA ┆ BA ┆ 2.0 │ #> └───────┴───────┴───────┘ duplicated_rows(pl_test, iso_o, iso_d) #> shape: (4, 3) #> ┌───────┬───────┬───────┐ #> │ iso_o ┆ iso_d ┆ value │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ f64 │ #> ╞═══════╪═══════╪═══════╡ #> │ AA ┆ BA ┆ 2.0 │ #> │ AA ┆ BA ┆ 2.0 │ #> │ AB ┆ BB ┆ 3.0 │ #> │ AB ┆ BB ┆ 4.0 │ #> └───────┴───────┴───────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/drop_na.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Drop missing values — drop_na.RPolarsDataFrame","title":"Drop missing values — drop_na.RPolarsDataFrame","text":"default, drop rows contain missing values. possible specify subset variables missing values variables considered.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/drop_na.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drop missing values — drop_na.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' drop_na(data, ...) # S3 method for class 'RPolarsLazyFrame' drop_na(data, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/drop_na.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Drop missing values — drop_na.RPolarsDataFrame","text":"data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/drop_na.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Drop missing values — drop_na.RPolarsDataFrame","text":"","code":"tmp <- mtcars tmp[1:3, \"mpg\"] <- NA tmp[4, \"hp\"] <- NA pl_tmp <- polars::pl$DataFrame(tmp) #> Warning: Passing a `data.frame` or `RPolarsDataFrame` to `pl$DataFrame()` is deprecated and will be removed in the future. Use `as_polars_df()` instead. drop_na(pl_tmp) #> shape: (28, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ 18.1 ┆ 6.0 ┆ 225.0 ┆ 105.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 14.3 ┆ 8.0 ┆ 360.0 ┆ 245.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 4.0 │ #> │ 24.4 ┆ 4.0 ┆ 146.7 ┆ 62.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ 22.8 ┆ 4.0 ┆ 140.8 ┆ 95.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘ drop_na(pl_tmp, hp, mpg) #> shape: (28, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ 18.1 ┆ 6.0 ┆ 225.0 ┆ 105.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 14.3 ┆ 8.0 ┆ 360.0 ┆ 245.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 4.0 │ #> │ 24.4 ┆ 4.0 ┆ 146.7 ┆ 62.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ 22.8 ┆ 4.0 ┆ 140.8 ┆ 95.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/explain.RPolarsLazyFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Show the optimized and non-optimized query plans — explain.RPolarsLazyFrame","title":"Show the optimized and non-optimized query plans — explain.RPolarsLazyFrame","text":"function available LazyFrames . default, explain() shows query plan optimized run Polars. Setting optimized = FALSE shows query plan -, without optimization done, query performed. Note plans read bottom top.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/explain.RPolarsLazyFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Show the optimized and non-optimized query plans — explain.RPolarsLazyFrame","text":"","code":"# S3 method for class 'RPolarsLazyFrame' explain(x, optimized = TRUE, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/explain.RPolarsLazyFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Show the optimized and non-optimized query plans — explain.RPolarsLazyFrame","text":"x Polars LazyFrame. optimized Logical. TRUE (default), show query optimized Polars. Otherwise, show initial query. ... Ignored.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/explain.RPolarsLazyFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Show the optimized and non-optimized query plans — explain.RPolarsLazyFrame","text":"","code":"query <- mtcars |> as_polars_lf() |> arrange(drat) |> filter(cyl == 3) |> select(mpg) # unoptimized query plan: no_opt <- explain(query, optimized = FALSE) no_opt #> [1] \" SELECT [col(\\\"mpg\\\")] FROM\\n FILTER [(col(\\\"cyl\\\")) == (3.0)] FROM\\n SORT BY [col(\\\"drat\\\")]\\n DF [\\\"mpg\\\", \\\"cyl\\\", \\\"disp\\\", \\\"hp\\\"]; PROJECT */11 COLUMNS; SELECTION: None\" # better printing with cat(): cat(no_opt) #> SELECT [col(\"mpg\")] FROM #> FILTER [(col(\"cyl\")) == (3.0)] FROM #> SORT BY [col(\"drat\")] #> DF [\"mpg\", \"cyl\", \"disp\", \"hp\"]; PROJECT */11 COLUMNS; SELECTION: None # optimized query run by polars cat(explain(query)) #> simple π 1/3 [\"mpg\"] #> SORT BY [col(\"drat\")] #> DF [\"mpg\", \"cyl\", \"disp\", \"hp\"]; PROJECT 3/11 COLUMNS; SELECTION: [(col(\"cyl\")) == (3.0)]"},{"path":"https://tidypolars.etiennebacher.com/reference/fetch.html","id":null,"dir":"Reference","previous_headings":"","what":"Fetch n rows of a LazyFrame — fetch","title":"Fetch n rows of a LazyFrame — fetch","text":"Fetch way collect first n rows LazyFrame. mainly used test query runs expected subset data using collect() full query. Note fetching n rows mean output actually contain n rows, see section 'Details' information.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/fetch.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fetch n rows of a LazyFrame — fetch","text":"","code":"fetch( .data, n_rows = 500, type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, comm_subplan_elim = TRUE, comm_subexpr_elim = TRUE, cluster_with_columns = TRUE, no_optimization = FALSE, streaming = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/fetch.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fetch n rows of a LazyFrame — fetch","text":".data Polars LazyFrame n_rows Number rows fetch. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). comm_subplan_elim Cache branching subplans occur self-joins unions (default TRUE). comm_subexpr_elim Cache common subexpressions (default TRUE). cluster_with_columns Combine sequential independent calls $with_columns(). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE. streaming Run parts query streaming fashion (alpha state). Default FALSE.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/fetch.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fetch n rows of a LazyFrame — fetch","text":"parameter n_rows indicates many rows LazyFrame used beginning query, guarantee n_rows returned. example, query contains filter join operations datasets, final number rows can lower n_rows. hand, appending rows query can lead output rows n_rows.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/reference/fetch.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fetch n rows of a LazyFrame — fetch","text":"","code":"dat_lazy <- polars::as_polars_df(iris)$lazy() # this will return 30 rows fetch(dat_lazy, 30) #> shape: (30, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬─────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 5.0 ┆ 3.0 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.4 ┆ 1.6 ┆ 0.4 ┆ setosa │ #> │ 5.2 ┆ 3.5 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.2 ┆ 3.4 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴─────────┘ # this will return less than 30 rows because there are less than 30 matches # for this filter in the whole dataset dat_lazy |> filter(Sepal.Length > 7.0) |> fetch(30) #> shape: (12, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 7.1 ┆ 3.0 ┆ 5.9 ┆ 2.1 ┆ virginica │ #> │ 7.6 ┆ 3.0 ┆ 6.6 ┆ 2.1 ┆ virginica │ #> │ 7.3 ┆ 2.9 ┆ 6.3 ┆ 1.8 ┆ virginica │ #> │ 7.2 ┆ 3.6 ┆ 6.1 ┆ 2.5 ┆ virginica │ #> │ 7.7 ┆ 3.8 ┆ 6.7 ┆ 2.2 ┆ virginica │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 7.2 ┆ 3.2 ┆ 6.0 ┆ 1.8 ┆ virginica │ #> │ 7.2 ┆ 3.0 ┆ 5.8 ┆ 1.6 ┆ virginica │ #> │ 7.4 ┆ 2.8 ┆ 6.1 ┆ 1.9 ┆ virginica │ #> │ 7.9 ┆ 3.8 ┆ 6.4 ┆ 2.0 ┆ virginica │ #> │ 7.7 ┆ 3.0 ┆ 6.1 ┆ 2.3 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/fill.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","title":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","text":"Fills missing values selected columns using next previous entry. useful common output format values repeated, recorded change.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/fill.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' fill(data, ..., .direction = c(\"down\", \"up\", \"downup\", \"updown\"))"},{"path":"https://tidypolars.etiennebacher.com/reference/fill.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","text":"data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. .direction Direction fill missing values. Either \"\" (default), \"\", \"downup\" (.e. first ) \"updown\" (first ).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/fill.RPolarsDataFrame.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","text":"grouped Data/LazyFrames, fill() applied within group, meaning fill across group boundaries.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/fill.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fill in missing values with previous or next value — fill.RPolarsDataFrame","text":"","code":"pl_test <- polars::pl$DataFrame(x = c(NA, 1), y = c(2, NA)) fill(pl_test, everything(), .direction = \"down\") #> shape: (2, 2) #> ┌──────┬─────┐ #> │ x ┆ y │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════╪═════╡ #> │ null ┆ 2.0 │ #> │ 1.0 ┆ 2.0 │ #> └──────┴─────┘ fill(pl_test, everything(), .direction = \"up\") #> shape: (2, 2) #> ┌─────┬──────┐ #> │ x ┆ y │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞═════╪══════╡ #> │ 1.0 ┆ 2.0 │ #> │ 1.0 ┆ null │ #> └─────┴──────┘ # with grouped data, it doesn't use values from other groups pl_grouped <- polars::pl$DataFrame( grp = rep(c(\"A\", \"B\"), each = 3), x = c(1, NA, NA, NA, 2, NA), y = c(3, NA, 4, NA, 3, 1) ) |> group_by(grp) fill(pl_grouped, x, y, .direction = \"down\") #> shape: (6, 3) #> ┌─────┬──────┬──────┐ #> │ grp ┆ x ┆ y │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ f64 │ #> ╞═════╪══════╪══════╡ #> │ A ┆ 1.0 ┆ 3.0 │ #> │ A ┆ 1.0 ┆ 3.0 │ #> │ A ┆ 1.0 ┆ 4.0 │ #> │ B ┆ null ┆ null │ #> │ B ┆ 2.0 ┆ 3.0 │ #> │ B ┆ 2.0 ┆ 1.0 │ #> └─────┴──────┴──────┘ #> Groups [2]: grp #> Maintain order: FALSE"},{"path":"https://tidypolars.etiennebacher.com/reference/filter.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Keep rows that match a condition — filter.RPolarsDataFrame","title":"Keep rows that match a condition — filter.RPolarsDataFrame","text":"function used subset data frame, retaining rows satisfy conditions. retained, row must produce value TRUE conditions. Note condition evaluates NA row dropped, unlike base subsetting [.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/filter.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Keep rows that match a condition — filter.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' filter(.data, ..., .by = NULL) # S3 method for class 'RPolarsLazyFrame' filter(.data, ..., .by = NULL)"},{"path":"https://tidypolars.etiennebacher.com/reference/filter.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Keep rows that match a condition — filter.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Expressions return logical value, defined terms variables data. multiple expressions included, combined & operator. rows conditions evaluate TRUE kept. .Optionally, selection columns group just operation, functioning alternative group_by(). group order maintained, use group_by() want control .","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/filter.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Keep rows that match a condition — filter.RPolarsDataFrame","text":"","code":"pl_iris <- polars::as_polars_df(iris) filter(pl_iris, Sepal.Length < 5, Species == \"setosa\") #> shape: (20, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬─────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═════════╡ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.4 ┆ 1.4 ┆ 0.3 ┆ setosa │ #> │ 4.4 ┆ 2.9 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4.4 ┆ 3.0 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.5 ┆ 2.3 ┆ 1.3 ┆ 0.3 ┆ setosa │ #> │ 4.4 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.8 ┆ 3.0 ┆ 1.4 ┆ 0.3 ┆ setosa │ #> │ 4.6 ┆ 3.2 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴─────────┘ filter(pl_iris, Sepal.Length < Sepal.Width + Petal.Length) #> shape: (115, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.4 ┆ 3.9 ┆ 1.7 ┆ 0.4 ┆ setosa │ #> │ 4.6 ┆ 3.4 ┆ 1.4 ┆ 0.3 ┆ setosa │ #> │ 4.8 ┆ 3.4 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 5.7 ┆ 4.4 ┆ 1.5 ┆ 0.4 ┆ setosa │ #> │ 5.1 ┆ 3.8 ┆ 1.5 ┆ 0.3 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ filter(pl_iris, Species == \"setosa\" | is.na(Species)) #> shape: (50, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬─────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4.8 ┆ 3.0 ┆ 1.4 ┆ 0.3 ┆ setosa │ #> │ 5.1 ┆ 3.8 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.2 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 5.3 ┆ 3.7 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.3 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴─────────┘ iris2 <- iris iris2$Species <- as.character(iris2$Species) iris2 |> as_polars_df() |> filter(Species %in% c(\"setosa\", \"virginica\")) #> shape: (100, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ str │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ # filter by group pl_iris |> group_by(Species) |> filter(Sepal.Length == max(Sepal.Length)) |> ungroup() #> shape: (3, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪════════════╡ #> │ 5.8 ┆ 4.0 ┆ 1.2 ┆ 0.2 ┆ setosa │ #> │ 7.0 ┆ 3.2 ┆ 4.7 ┆ 1.4 ┆ versicolor │ #> │ 7.9 ┆ 3.8 ┆ 6.4 ┆ 2.0 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴────────────┘ # an alternative syntax for grouping is to use `.by` pl_iris |> filter(Sepal.Length == max(Sepal.Length), .by = Species) #> shape: (3, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪════════════╡ #> │ 5.8 ┆ 4.0 ┆ 1.2 ┆ 0.2 ┆ setosa │ #> │ 7.0 ┆ 3.2 ┆ 4.7 ┆ 1.4 ┆ versicolor │ #> │ 7.9 ┆ 3.8 ┆ 6.4 ┆ 2.0 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/from_csv.html","id":null,"dir":"Reference","previous_headings":"","what":"Import data from CSV file(s) — from_csv","title":"Import data from CSV file(s) — from_csv","text":"read_csv_polars() imports data Polars DataFrame. scan_csv_polars() imports data Polars LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_csv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import data from CSV file(s) — from_csv","text":"","code":"read_csv_polars( source, ..., has_header = TRUE, separator = \",\", comment_prefix = NULL, quote_char = \"\\\"\", skip_rows = 0, dtypes = NULL, null_values = NULL, ignore_errors = FALSE, cache = FALSE, infer_schema_length = 100, n_rows = NULL, encoding = \"utf8\", low_memory = FALSE, rechunk = TRUE, skip_rows_after_header = 0, row_index_name = NULL, row_index_offset = 0, try_parse_dates = FALSE, eol_char = \"\\n\", raise_if_empty = TRUE, truncate_ragged_lines = FALSE, reuse_downloaded = TRUE ) scan_csv_polars( source, ..., has_header = TRUE, separator = \",\", comment_prefix = NULL, quote_char = \"\\\"\", skip_rows = 0, dtypes = NULL, null_values = NULL, ignore_errors = FALSE, cache = FALSE, infer_schema_length = 100, n_rows = NULL, encoding = \"utf8\", low_memory = FALSE, rechunk = TRUE, skip_rows_after_header = 0, row_index_name = NULL, row_index_offset = 0, try_parse_dates = FALSE, eol_char = \"\\n\", raise_if_empty = TRUE, truncate_ragged_lines = FALSE, reuse_downloaded = TRUE )"},{"path":"https://tidypolars.etiennebacher.com/reference/from_csv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import data from CSV file(s) — from_csv","text":"source Path file URL. possible provide multiple paths provided CSV files schema. possible provide several URLs. ... Ignored. has_header Indicate first row dataset header .FALSE, column names autogenerated following format: \"column_x\" x enumeration every column dataset starting 1. separator Single byte character use separator file. comment_prefix string, can 5 symbols length, used indicate start comment line. instance, can set # //. quote_char Single byte character used quoting. Set NULL turn special handling escaping quotes. skip_rows Start reading particular number rows. header parsed offset. dtypes Named list column names - dtypes dtype - column names. list used reading overwrite dtypes. Supported types far : \"Boolean\" \"logical\" DataType::Boolean, \"Categorical\" \"factor\" DataType::Categorical, \"Float32\" \"double\" DataType::Float32, \"Float64\" \"float64\" DataType::Float64, \"Int32\" \"integer\" DataType::Int32, \"Int64\" \"integer64\" DataType::Int64, \"String\" \"character\" DataType::String, null_values Values interpret NA values. Can : character vector: values match one values vector NA; named list column names null values. ignore_errors Keep reading file even lines yield errors. can also use infer_schema_length = 0 read columns UTF8 check values might cause issue. cache Cache result reading. infer_schema_length Maximum number rows read infer column types. set 0, columns read UTF-8. NULL, full table scan done (slow). n_rows Maximum number rows read. encoding Either \"utf8\" \"utf8-lossy\". Lossy means invalid UTF8 values replaced \"?\" characters. low_memory Reduce memory usage (yield lower performance). rechunk Reallocate contiguous memory chunks / files parsed. skip_rows_after_header Parse first row headers, skip number rows. row_index_name NULL, insert row index column given name DataFrame. row_index_offset Offset start row index column (used name set). try_parse_dates Try automatically parse dates. ISO8601-like formats can inferred, well handful others. succeed, column remains data type pl$String. eol_char Single byte end line character (default: \\n). encountering file Windows line endings (\\r\\n), one can go default \\n. extra \\r removed processed. raise_if_empty FALSE, parsing empty file returns empty DataFrame LazyFrame. truncate_ragged_lines Truncate lines longer schema. reuse_downloaded TRUE(default) URL provided, cache downloaded files session easy reuse.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_ipc.html","id":null,"dir":"Reference","previous_headings":"","what":"Import data from IPC file(s) — from_ipc","title":"Import data from IPC file(s) — from_ipc","text":"read_ipc_polars() imports data Polars DataFrame. scan_ipc_polars() imports data Polars LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_ipc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import data from IPC file(s) — from_ipc","text":"","code":"read_ipc_polars( source, ..., n_rows = NULL, memory_map = TRUE, row_index_name = NULL, row_index_offset = 0L, rechunk = FALSE, cache = TRUE, include_file_paths = NULL ) scan_ipc_polars( source, ..., n_rows = NULL, memory_map = TRUE, row_index_name = NULL, row_index_offset = 0L, rechunk = FALSE, cache = TRUE, include_file_paths = NULL )"},{"path":"https://tidypolars.etiennebacher.com/reference/from_ipc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import data from IPC file(s) — from_ipc","text":"source Path file. can use globbing * scan/read multiple files directory (see examples). ... Ignored. n_rows Maximum number rows read. memory_map logical. TRUE, try memory map file. can greatly improve performance repeated queries OS may cache pages. uncompressed Arrow IPC files can memory mapped. row_index_name NULL, insert row index column given name DataFrame. row_index_offset Offset start row index column (used name set). rechunk case reading multiple files via glob pattern, rechunk final DataFrame contiguous memory chunks. cache Cache result reading. include_file_paths Character value indicating column name include path source file(s).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_ipc.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Import data from IPC file(s) — from_ipc","text":"Hive-style partitioning supported yet.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_ndjson.html","id":null,"dir":"Reference","previous_headings":"","what":"Import data from NDJSON file(s) — from_ndjson","title":"Import data from NDJSON file(s) — from_ndjson","text":"read_ndjson_polars() imports data Polars DataFrame. scan_ndjson_polars() imports data Polars LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_ndjson.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import data from NDJSON file(s) — from_ndjson","text":"","code":"read_ndjson_polars( source, ..., infer_schema_length = 100, batch_size = NULL, n_rows = NULL, low_memory = FALSE, rechunk = FALSE, row_index_name = NULL, row_index_offset = 0, reuse_downloaded = TRUE, ignore_errors = FALSE ) scan_ndjson_polars( source, ..., infer_schema_length = 100, batch_size = NULL, n_rows = NULL, low_memory = FALSE, rechunk = FALSE, row_index_name = NULL, row_index_offset = 0, reuse_downloaded = TRUE, ignore_errors = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/from_ndjson.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import data from NDJSON file(s) — from_ndjson","text":"source Path file URL. possible provide multiple paths provided NDJSON files schema. possible provide several URLs. ... Ignored. infer_schema_length Maximum number rows read infer column types. set 0, columns read UTF-8. NULL, full table scan done (slow). batch_size Number rows processed per thread. n_rows Maximum number rows read. low_memory Reduce memory usage (yield lower performance). rechunk Reallocate contiguous memory chunks / files parsed. row_index_name NULL, insert row index column given name DataFrame. row_index_offset Offset start row index column (used name set). reuse_downloaded TRUE(default) URL provided, cache downloaded files session easy reuse. ignore_errors Keep reading file even lines yield errors. can also use infer_schema_length = 0 read columns UTF8 check values might cause issue.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":null,"dir":"Reference","previous_headings":"","what":"Import data from Parquet file(s) — from_parquet","title":"Import data from Parquet file(s) — from_parquet","text":"read_parquet_polars() imports data Polars DataFrame. scan_parquet_polars() imports data Polars LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import data from Parquet file(s) — from_parquet","text":"","code":"read_parquet_polars( source, ..., n_rows = NULL, row_index_name = NULL, row_index_offset = 0L, parallel = \"auto\", hive_partitioning = NULL, hive_schema = NULL, try_parse_hive_dates = TRUE, glob = TRUE, rechunk = TRUE, low_memory = FALSE, storage_options = NULL, use_statistics = TRUE, cache = TRUE, include_file_paths = NULL ) scan_parquet_polars( source, ..., n_rows = NULL, row_index_name = NULL, row_index_offset = 0L, parallel = \"auto\", hive_partitioning = NULL, hive_schema = NULL, try_parse_hive_dates = TRUE, glob = TRUE, rechunk = FALSE, low_memory = FALSE, storage_options = NULL, use_statistics = TRUE, cache = TRUE, include_file_paths = NULL )"},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import data from Parquet file(s) — from_parquet","text":"source Path file. can use globbing * scan/read multiple files directory (see examples). ... Ignored. n_rows Maximum number rows read. row_index_name NULL, insert row index column given name DataFrame. row_index_offset Offset start row index column (used name set). parallel determines direction parallelism. \"auto\" try determine optimal direction. Can \"auto\", \"columns\", \"row_groups\", \"prefiltered\", \"none\". See 'Details'. hive_partitioning Infer statistics schema Hive partitioned URL use prune reads. NULL (default), automatically enabled single directory passed, otherwise disabled. hive_schema list containing column names data types columns data partitioned, e.g. list(= pl$String, b = pl$Float32). NULL (default), schema Hive partitions inferred. try_parse_hive_dates Whether try parsing hive values date/datetime types. glob Expand path given via globbing rules. rechunk case reading multiple files via glob pattern, rechunk final DataFrame contiguous memory chunks. low_memory Reduce memory usage (yield lower performance). storage_options Experimental. List options necessary scan parquet files different cloud storage providers (GCP, AWS, Azure, HuggingFace). See 'Details' section. use_statistics Use statistics parquet file determine pages can skipped reading. cache Cache result reading. include_file_paths Include path source file(s) column name.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":"on-parallel-strategies","dir":"Reference","previous_headings":"","what":"On parallel strategies","title":"Import data from Parquet file(s) — from_parquet","text":"prefiltered strategy first evaluates pushed-predicates parallel determines mask rows read. , parallelizes columns row groups filtering rows need read. can provide significant speedups large files (.e. many row-groups) predicate filters clustered rows filters heavily. cases, prefiltered may slow scan compared strategies. prefiltered settings falls back auto predicate given.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":"connecting-to-cloud-providers","dir":"Reference","previous_headings":"","what":"Connecting to cloud providers","title":"Import data from Parquet file(s) — from_parquet","text":"Polars supports scanning parquet files different cloud providers. cloud providers currently supported AWS, GCP, Azure. supported keys pass storage_options argument can found : aws gcp azure Currently impossible scan public parquet files GCP without valid service account. sure always include service account storage_options argument.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/from_parquet.html","id":"scanning-from-huggingface","dir":"Reference","previous_headings":"","what":"Scanning from HuggingFace","title":"Import data from Parquet file(s) — from_parquet","text":"possible scan data stored HuggingFace using path starting hf://. hf:// path format defined hf://BUCKET/REPOSITORY@REVISION/PATH, : BUCKET one datasets spaces REPOSITORY location repository. usually format username/repo_name. branch can also optionally specified appending @branch. REVISION name branch (commit) use. optional defaults main given. PATH file directory path, glob pattern repository root. Hugging Face API key can passed access private locations using either following methods: Passing token storage_options scan function, e.g. scan_parquet(..., storage_options = list(token = )) Setting HF_TOKEN environment variable, e.g. Sys.setenv(HF_TOKEN = ).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_by.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Group by one or more variables — group_by.RPolarsDataFrame","title":"Group by one or more variables — group_by.RPolarsDataFrame","text":"data operations done groups defined variables. group_by() takes existing Polars Data/LazyFrame converts grouped one operations performed \"group\". ungroup() removes grouping.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_by.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Group by one or more variables — group_by.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' group_by(.data, ..., maintain_order = FALSE, .add = FALSE) # S3 method for class 'RPolarsDataFrame' ungroup(x, ...) # S3 method for class 'RPolarsLazyFrame' group_by(.data, ..., maintain_order = FALSE, .add = FALSE) # S3 method for class 'RPolarsLazyFrame' ungroup(x, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/group_by.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Group by one or more variables — group_by.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Variables group (used group_by() ). used ungroup(). maintain_order Maintain row order. performance reasons, FALSE default). Setting TRUE can slow process large datasets prevents use streaming. .add FALSE (default), group_by() override existing groups. add existing groups, use .add = TRUE. x Polars Data/LazyFrame","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_by.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Group by one or more variables — group_by.RPolarsDataFrame","text":"","code":"by_cyl <- mtcars |> as_polars_df() |> group_by(cyl) by_cyl #> shape: (32, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘ #> Groups [3]: cyl #> Maintain order: FALSE by_cyl |> summarise( disp = mean(disp), hp = mean(hp) ) #> shape: (3, 3) #> ┌─────┬────────────┬────────────┐ #> │ cyl ┆ disp ┆ hp │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪════════════╪════════════╡ #> │ 8.0 ┆ 353.1 ┆ 209.214286 │ #> │ 6.0 ┆ 183.314286 ┆ 122.285714 │ #> │ 4.0 ┆ 105.136364 ┆ 82.636364 │ #> └─────┴────────────┴────────────┘ by_cyl |> filter(disp == max(disp)) #> shape: (3, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 24.4 ┆ 4.0 ┆ 146.7 ┆ 62.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ 10.4 ┆ 8.0 ┆ 472.0 ┆ 205.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 4.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘ #> Groups [3]: cyl #> Maintain order: FALSE"},{"path":"https://tidypolars.etiennebacher.com/reference/group_split.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Grouping metadata — group_split.RPolarsDataFrame","title":"Grouping metadata — group_split.RPolarsDataFrame","text":"group_vars() returns character vector names grouping variables. group_keys() returns data frame one row per group.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_split.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Grouping metadata — group_split.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' group_split(.tbl, ..., .keep = TRUE)"},{"path":"https://tidypolars.etiennebacher.com/reference/group_split.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Grouping metadata — group_split.RPolarsDataFrame","text":".tbl Polars Data/LazyFrame ... .tbl grouped, variables group . .tbl already grouped, ignored. .keep grouping columns kept?","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_split.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Grouping metadata — group_split.RPolarsDataFrame","text":"","code":"pl_g <- polars::as_polars_df(iris) |> group_by(Species) group_split(pl_g) #> [[1]] #> shape: (50, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬─────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4.8 ┆ 3.0 ┆ 1.4 ┆ 0.3 ┆ setosa │ #> │ 5.1 ┆ 3.8 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.2 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 5.3 ┆ 3.7 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.3 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴─────────┘ #> #> [[2]] #> shape: (50, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪════════════╡ #> │ 7.0 ┆ 3.2 ┆ 4.7 ┆ 1.4 ┆ versicolor │ #> │ 6.4 ┆ 3.2 ┆ 4.5 ┆ 1.5 ┆ versicolor │ #> │ 6.9 ┆ 3.1 ┆ 4.9 ┆ 1.5 ┆ versicolor │ #> │ 5.5 ┆ 2.3 ┆ 4.0 ┆ 1.3 ┆ versicolor │ #> │ 6.5 ┆ 2.8 ┆ 4.6 ┆ 1.5 ┆ versicolor │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 5.7 ┆ 3.0 ┆ 4.2 ┆ 1.2 ┆ versicolor │ #> │ 5.7 ┆ 2.9 ┆ 4.2 ┆ 1.3 ┆ versicolor │ #> │ 6.2 ┆ 2.9 ┆ 4.3 ┆ 1.3 ┆ versicolor │ #> │ 5.1 ┆ 2.5 ┆ 3.0 ┆ 1.1 ┆ versicolor │ #> │ 5.7 ┆ 2.8 ┆ 4.1 ┆ 1.3 ┆ versicolor │ #> └──────────────┴─────────────┴──────────────┴─────────────┴────────────┘ #> #> [[3]] #> shape: (50, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 6.3 ┆ 3.3 ┆ 6.0 ┆ 2.5 ┆ virginica │ #> │ 5.8 ┆ 2.7 ┆ 5.1 ┆ 1.9 ┆ virginica │ #> │ 7.1 ┆ 3.0 ┆ 5.9 ┆ 2.1 ┆ virginica │ #> │ 6.3 ┆ 2.9 ┆ 5.6 ┆ 1.8 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.8 ┆ 2.2 ┆ virginica │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ #>"},{"path":"https://tidypolars.etiennebacher.com/reference/group_vars.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Grouping metadata — group_vars.RPolarsDataFrame","title":"Grouping metadata — group_vars.RPolarsDataFrame","text":"group_vars() returns character vector names grouping variables. group_keys() returns data frame one row per group.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_vars.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Grouping metadata — group_vars.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' group_vars(x) # S3 method for class 'RPolarsLazyFrame' group_vars(x) # S3 method for class 'RPolarsDataFrame' group_keys(.tbl, ...) # S3 method for class 'RPolarsLazyFrame' group_keys(.tbl, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/group_vars.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Grouping metadata — group_vars.RPolarsDataFrame","text":"x, .tbl Polars Data/LazyFrame ... dots future extensions must empty.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/group_vars.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Grouping metadata — group_vars.RPolarsDataFrame","text":"","code":"pl_g <- polars::as_polars_df(mtcars) |> group_by(cyl, am) group_vars(pl_g) #> [1] \"cyl\" \"am\" group_keys(pl_g) #> cyl am #> 1 4 0 #> 2 4 1 #> 3 6 0 #> 4 6 1 #> 5 8 0 #> 6 8 1"},{"path":"https://tidypolars.etiennebacher.com/reference/make_unique_id.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a column with unique id per row values — make_unique_id","title":"Create a column with unique id per row values — make_unique_id","text":"Create column unique id per row values","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/make_unique_id.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a column with unique id per row values — make_unique_id","text":"","code":"make_unique_id(.data, ..., new_col = \"hash\")"},{"path":"https://tidypolars.etiennebacher.com/reference/make_unique_id.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a column with unique id per row values — make_unique_id","text":".data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. new_col Name new column","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/make_unique_id.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a column with unique id per row values — make_unique_id","text":"","code":"mtcars |> as_polars_df() |> make_unique_id(am, gear) #> shape: (32, 12) #> ┌──────┬─────┬───────┬───────┬───┬─────┬──────┬──────┬──────────────────────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ am ┆ gear ┆ carb ┆ hash │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ u64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪══════╪══════╪══════════════════════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 6713333141368562554 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 6713333141368562554 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 1.0 ┆ 6713333141368562554 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 1.0 ┆ 16798766010850734252 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 3.0 ┆ 2.0 ┆ 16798766010850734252 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 2.0 ┆ 6990942474477480077 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 4.0 ┆ 6990942474477480077 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 6.0 ┆ 6990942474477480077 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 1.0 ┆ 5.0 ┆ 8.0 ┆ 6990942474477480077 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 2.0 ┆ 6713333141368562554 │ #> └──────┴─────┴───────┴───────┴───┴─────┴──────┴──────┴──────────────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/mutate.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Create, modify, and delete columns — mutate.RPolarsDataFrame","title":"Create, modify, and delete columns — mutate.RPolarsDataFrame","text":"creates new columns functions existing variables. can also modify (name existing column) delete columns (setting value NULL).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutate.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create, modify, and delete columns — mutate.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' mutate(.data, ..., .by = NULL, .keep = c(\"all\", \"used\", \"unused\", \"none\")) # S3 method for class 'RPolarsLazyFrame' mutate(.data, ..., .by = NULL, .keep = c(\"all\", \"used\", \"unused\", \"none\"))"},{"path":"https://tidypolars.etiennebacher.com/reference/mutate.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create, modify, and delete columns — mutate.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Name-value pairs. name gives name column output. value can : vector length current group (whole data frame ungrouped). NULL, remove column. across() mostly supported, except cases. particular, .cols argument (...), select variables created across(). select helpers supported. See examples. .Optionally, selection columns group just operation, functioning alternative group_by(). group order maintained, use group_by() want control . .keep Control columns .data retained output. Grouping columns columns created ... always kept. \"\" retains columns .data. default. \"used\" retains columns used ... create new columns. useful checking work, displays inputs outputs side-- side. \"unused\" retains columns used ... create new columns. useful generate new columns, longer need columns used generate . \"none\" retain extra columns .data. grouping variables columns created ... kept.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutate.RPolarsDataFrame.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create, modify, and delete columns — mutate.RPolarsDataFrame","text":"lot functions available base R (cos, mean, multiplying, etc.) packages (dplyr::lag(), etc.) implemented efficient way Polars. functions automatically translated Polars syntax hood can continue using classic R syntax functions. Polars built-replacement exist (example custom functions), tidypolars throw error. See vignette Polars expressions know write custom functions accepted tidypolars.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutate.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create, modify, and delete columns — mutate.RPolarsDataFrame","text":"","code":"pl_iris <- polars::as_polars_df(iris) # classic operation mutate(pl_iris, x = Sepal.Width + Sepal.Length) #> shape: (150, 6) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬─────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ x │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪═════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 8.6 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 7.9 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ 7.9 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ 7.7 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 8.6 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ 9.7 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ 8.8 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ 9.5 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ 9.6 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ 8.9 │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴─────┘ # logical operation mutate(pl_iris, x = Sepal.Width > Sepal.Length & Petal.Width > Petal.Length) #> shape: (150, 6) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬───────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ x │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ bool │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪═══════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ false │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ false │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ false │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ false │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ false │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ false │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ false │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ false │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ false │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ false │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴───────┘ # overwrite existing variable mutate(pl_iris, Sepal.Width = Sepal.Width * 2) #> shape: (150, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.1 ┆ 7.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 6.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 6.4 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 6.2 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 7.2 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 6.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 5.0 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 6.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 6.8 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 6.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ # grouped computation pl_iris |> group_by(Species) |> mutate(foo = mean(Sepal.Length)) #> shape: (150, 6) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬───────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ foo │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪═══════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ 6.588 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ 6.588 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ 6.588 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ 6.588 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ 6.588 │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴───────┘ #> Groups [3]: Species #> Maintain order: FALSE # an alternative syntax for grouping is to use `.by` pl_iris |> mutate(foo = mean(Sepal.Length), .by = Species) #> shape: (150, 6) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬───────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ foo │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪═══════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.006 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ 6.588 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ 6.588 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ 6.588 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ 6.588 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ 6.588 │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴───────┘ # across() is available pl_iris |> mutate( across(.cols = contains(\"Sepal\"), .fns = mean, .names = \"{.fn}_of_{.col}\") ) #> shape: (150, 7) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬──────────────┬─────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ mean_of_Sepa ┆ mean_of_Sep │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ l.Length ┆ al.Width │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ --- ┆ --- │ #> │ ┆ ┆ ┆ ┆ ┆ f64 ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪══════════════╪═════════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.843333 ┆ 3.057333 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.843333 ┆ 3.057333 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ 5.843333 ┆ 3.057333 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ 5.843333 ┆ 3.057333 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 5.843333 ┆ 3.057333 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ 5.843333 ┆ 3.057333 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ 5.843333 ┆ 3.057333 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ 5.843333 ┆ 3.057333 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ 5.843333 ┆ 3.057333 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ 5.843333 ┆ 3.057333 │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴──────────────┴─────────────┘ # # It can receive several types of functions: pl_iris |> mutate( across( .cols = contains(\"Sepal\"), .fns = list(mean = mean, sd = ~ sd(.x)), .names = \"{.fn}_of_{.col}\" ) ) #> shape: (150, 9) #> ┌───────────┬───────────┬───────────┬───────────┬───┬───────────┬───────────┬───────────┬──────────┐ #> │ Sepal.Len ┆ Sepal.Wid ┆ Petal.Len ┆ Petal.Wid ┆ … ┆ mean_of_S ┆ sd_of_Sep ┆ mean_of_S ┆ sd_of_Se │ #> │ gth ┆ th ┆ gth ┆ th ┆ ┆ epal.Leng ┆ al.Length ┆ epal.Widt ┆ pal.Widt │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ th ┆ --- ┆ h ┆ h │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ --- ┆ f64 ┆ --- ┆ --- │ #> │ ┆ ┆ ┆ ┆ ┆ f64 ┆ ┆ f64 ┆ f64 │ #> ╞═══════════╪═══════════╪═══════════╪═══════════╪═══╪═══════════╪═══════════╪═══════════╪══════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ … ┆ 5.843333 ┆ 0.828066 ┆ 3.057333 ┆ 0.435866 │ #> └───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴───────────┴──────────┘ # Be careful when using across(.cols = where(...), ...) as it will not include # variables created in the same `...` (this is only the case for `where()`): if (FALSE) { # \\dontrun{ pl_iris |> mutate( foo = 1, across( .cols = where(is.numeric), \\(x) x - 1000 # <<<<<<<<< this will not be applied on variable \"foo\" ) ) } # } # Warning message: # In `across()`, the argument `.cols = where(is.numeric)` will not take into account # variables created in the same `mutate()`/`summarize` call. # Embracing an external variable works some_value <- 1 mutate(pl_iris, x = {{ some_value }}) #> shape: (150, 6) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┬─────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species ┆ x │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╪═════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 1.0 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 1.0 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa ┆ 1.0 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa ┆ 1.0 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa ┆ 1.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica ┆ 1.0 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica ┆ 1.0 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica ┆ 1.0 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica ┆ 1.0 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica ┆ 1.0 │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┴─────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/mutating-joins.html","id":null,"dir":"Reference","previous_headings":"","what":"Mutating joins — left_join.RPolarsDataFrame","title":"Mutating joins — left_join.RPolarsDataFrame","text":"Mutating joins add columns y x, matching observations based keys.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutating-joins.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mutating joins — left_join.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' left_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsDataFrame' right_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsDataFrame' full_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsDataFrame' inner_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsLazyFrame' left_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsLazyFrame' right_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsLazyFrame' full_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL ) # S3 method for class 'RPolarsLazyFrame' inner_join( x, y, by = NULL, copy = FALSE, suffix = c(\".x\", \".y\"), ..., keep = NULL, na_matches = \"na\", relationship = NULL )"},{"path":"https://tidypolars.etiennebacher.com/reference/mutating-joins.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mutating joins — left_join.RPolarsDataFrame","text":"x, y Two Polars Data/LazyFrames Variables join . NULL (default), *_join() perform natural join, using variables common across x y. message lists variables can check correct; suppress message supplying explicitly. can take character vector, like c(\"x\", \"y\") x y datasets. join variables name, use equalities character vector, like c(\"x1\" = \"x2\", \"y\"). use character vector, join can done using strict equality. can also specification created dplyr::join_by(). Contrary input character vector shown , join_by() uses unquoted column names, e.g join_by(x1 == x2, y). Finally, inner_join() also supports inequality joins, e.g. join_by(x1 >= x2), helpers (), overlaps(), within(). See documentation dplyr::join_by() information. join types likely support inequality joins future. copy, keep supported. suffix non-joined duplicate variables x y, suffixes added output disambiguate . character vector length 2. ... Dots empty. na_matches two NA values match? \"na\", default, treats two NA values equal. \"never\" treats two NA values different never match together values. Note joining Polars Data/LazyFrames, NaN always considered equal, matter value na_matches. differs original dplyr implementation. relationship Handling expected relationship keys x y. Must one following: NULL, default, equivalent \"many--many\". expect relationship x y. \"one--one\" expects row x match 1 row y row y match 1 row x. \"one--many\" expects row y match 1 row x. \"many--one\" expects row x matches 1 row y.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutating-joins.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Mutating joins — left_join.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/mutating-joins.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mutating joins — left_join.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame( x = c(1, 2, 3), y1 = c(1, 2, 3), z = c(1, 2, 3) ) test2 <- polars::pl$DataFrame( x = c(1, 2, 4), y2 = c(1, 2, 4), z2 = c(4, 5, 7) ) test #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y1 ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 │ #> └─────┴─────┴─────┘ test2 #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y2 ┆ z2 │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 1.0 ┆ 1.0 ┆ 4.0 │ #> │ 2.0 ┆ 2.0 ┆ 5.0 │ #> │ 4.0 ┆ 4.0 ┆ 7.0 │ #> └─────┴─────┴─────┘ # default is to use common columns, here \"x\" only left_join(test, test2) #> Joining by `x` #> shape: (3, 5) #> ┌─────┬─────┬─────┬──────┬──────┐ #> │ x ┆ y1 ┆ z ┆ y2 ┆ z2 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╪══════╪══════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 4.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 ┆ 2.0 ┆ 5.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 ┆ null ┆ null │ #> └─────┴─────┴─────┴──────┴──────┘ # we can specify the columns on which to join with join_by()... left_join(test, test2, by = join_by(x, y1 == y2)) #> shape: (3, 4) #> ┌─────┬─────┬─────┬──────┐ #> │ x ┆ y1 ┆ z ┆ z2 │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╪══════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 ┆ 4.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 ┆ 5.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 ┆ null │ #> └─────┴─────┴─────┴──────┘ # ... or with a character vector left_join(test, test2, by = c(\"x\", \"y1\" = \"y2\")) #> shape: (3, 4) #> ┌─────┬─────┬─────┬──────┐ #> │ x ┆ y1 ┆ z ┆ z2 │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╪══════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 ┆ 4.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 ┆ 5.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 ┆ null │ #> └─────┴─────┴─────┴──────┘ # we can customize the suffix of common column names not used to join test2 <- polars::pl$DataFrame( x = c(1, 2, 4), y1 = c(1, 2, 4), z = c(4, 5, 7) ) left_join(test, test2, by = \"x\", suffix = c(\"_left\", \"_right\")) #> shape: (3, 5) #> ┌─────┬─────────┬────────┬──────────┬─────────┐ #> │ x ┆ y1_left ┆ z_left ┆ y1_right ┆ z_right │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════════╪════════╪══════════╪═════════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 4.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 ┆ 2.0 ┆ 5.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 ┆ null ┆ null │ #> └─────┴─────────┴────────┴──────────┴─────────┘ # the argument \"relationship\" ensures the join matches the expectation country <- polars::pl$DataFrame( iso = c(\"FRA\", \"DEU\"), value = 1:2 ) country #> shape: (2, 2) #> ┌─────┬───────┐ #> │ iso ┆ value │ #> │ --- ┆ --- │ #> │ str ┆ i32 │ #> ╞═════╪═══════╡ #> │ FRA ┆ 1 │ #> │ DEU ┆ 2 │ #> └─────┴───────┘ country_year <- polars::pl$DataFrame( iso = rep(c(\"FRA\", \"DEU\"), each = 2), year = rep(2019:2020, 2), value2 = 3:6 ) country_year #> shape: (4, 3) #> ┌─────┬──────┬────────┐ #> │ iso ┆ year ┆ value2 │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ i32 │ #> ╞═════╪══════╪════════╡ #> │ FRA ┆ 2019 ┆ 3 │ #> │ FRA ┆ 2020 ┆ 4 │ #> │ DEU ┆ 2019 ┆ 5 │ #> │ DEU ┆ 2020 ┆ 6 │ #> └─────┴──────┴────────┘ # We expect that each row in \"x\" matches only one row in \"y\" but, it's not # true as each row of \"x\" matches two rows of \"y\" tryCatch( left_join(country, country_year, join_by(iso), relationship = \"one-to-one\"), error = function(e) e ) #> 0: In R: in $collect(): #> 0: During function call [pkgdown::build_site_github_pages(new_process = FALSE, install = TRUE)] #> 1: Encountered the following error in Rust-Polars: #> \tjoin keys did not fulfill 1:1 validation #> > # A correct expectation would be \"one-to-many\": left_join(country, country_year, join_by(iso), relationship = \"one-to-many\") #> shape: (4, 4) #> ┌─────┬───────┬──────┬────────┐ #> │ iso ┆ value ┆ year ┆ value2 │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ i32 ┆ i32 │ #> ╞═════╪═══════╪══════╪════════╡ #> │ FRA ┆ 1 ┆ 2019 ┆ 3 │ #> │ FRA ┆ 1 ┆ 2020 ┆ 4 │ #> │ DEU ┆ 2 ┆ 2019 ┆ 5 │ #> │ DEU ┆ 2 ┆ 2020 ┆ 6 │ #> └─────┴───────┴──────┴────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_longer.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","title":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","text":"Pivot Data/LazyFrame wide long","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_longer.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' pivot_longer( data, cols, ..., names_to = \"name\", names_prefix = NULL, values_to = \"value\" ) # S3 method for class 'RPolarsLazyFrame' pivot_longer( data, cols, ..., names_to = \"name\", names_prefix = NULL, values_to = \"value\" )"},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_longer.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","text":"data Polars Data/LazyFrame cols Columns pivot longer format. Can anything accepted dplyr::select(). ... Dots empty. names_to (quoted) name column contain column names specified cols. names_prefix regular expression used remove matching text start variable name. values_to string specifying name column create data stored cell values.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_longer.RPolarsDataFrame.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_longer.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Pivot a Data/LazyFrame from wide to long — pivot_longer.RPolarsDataFrame","text":"","code":"pl_relig_income <- polars::pl$DataFrame(tidyr::relig_income) #> Warning: Passing a `data.frame` or `RPolarsDataFrame` to `pl$DataFrame()` is deprecated and will be removed in the future. Use `as_polars_df()` instead. pl_relig_income #> shape: (18, 11) #> ┌────────────────────┬───────┬─────────┬─────────┬───┬──────────┬───────────┬───────┬──────────────┐ #> │ religion ┆ <$10k ┆ $10-20k ┆ $20-30k ┆ … ┆ $75-100k ┆ $100-150k ┆ >150k ┆ Don't │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ know/refused │ #> │ str ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ --- │ #> │ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ f64 │ #> ╞════════════════════╪═══════╪═════════╪═════════╪═══╪══════════╪═══════════╪═══════╪══════════════╡ #> │ Agnostic ┆ 27.0 ┆ 34.0 ┆ 60.0 ┆ … ┆ 122.0 ┆ 109.0 ┆ 84.0 ┆ 96.0 │ #> │ Atheist ┆ 12.0 ┆ 27.0 ┆ 37.0 ┆ … ┆ 73.0 ┆ 59.0 ┆ 74.0 ┆ 76.0 │ #> │ Buddhist ┆ 27.0 ┆ 21.0 ┆ 30.0 ┆ … ┆ 62.0 ┆ 39.0 ┆ 53.0 ┆ 54.0 │ #> │ Catholic ┆ 418.0 ┆ 617.0 ┆ 732.0 ┆ … ┆ 949.0 ┆ 792.0 ┆ 633.0 ┆ 1489.0 │ #> │ Don’t know/refused ┆ 15.0 ┆ 14.0 ┆ 15.0 ┆ … ┆ 21.0 ┆ 17.0 ┆ 18.0 ┆ 116.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ Orthodox ┆ 13.0 ┆ 17.0 ┆ 23.0 ┆ … ┆ 38.0 ┆ 42.0 ┆ 46.0 ┆ 73.0 │ #> │ Other Christian ┆ 9.0 ┆ 7.0 ┆ 11.0 ┆ … ┆ 18.0 ┆ 14.0 ┆ 12.0 ┆ 18.0 │ #> │ Other Faiths ┆ 20.0 ┆ 33.0 ┆ 40.0 ┆ … ┆ 46.0 ┆ 40.0 ┆ 41.0 ┆ 71.0 │ #> │ Other World ┆ 5.0 ┆ 2.0 ┆ 3.0 ┆ … ┆ 3.0 ┆ 4.0 ┆ 4.0 ┆ 8.0 │ #> │ Religions ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │ #> │ Unaffiliated ┆ 217.0 ┆ 299.0 ┆ 374.0 ┆ … ┆ 407.0 ┆ 321.0 ┆ 258.0 ┆ 597.0 │ #> └────────────────────┴───────┴─────────┴─────────┴───┴──────────┴───────────┴───────┴──────────────┘ pl_relig_income |> pivot_longer(!religion, names_to = \"income\", values_to = \"count\") #> shape: (180, 3) #> ┌──────────────┬────────────────────┬───────┐ #> │ religion ┆ income ┆ count │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ f64 │ #> ╞══════════════╪════════════════════╪═══════╡ #> │ Agnostic ┆ <$10k ┆ 27.0 │ #> │ Agnostic ┆ $10-20k ┆ 34.0 │ #> │ Agnostic ┆ $20-30k ┆ 60.0 │ #> │ Agnostic ┆ $30-40k ┆ 81.0 │ #> │ Agnostic ┆ $40-50k ┆ 76.0 │ #> │ … ┆ … ┆ … │ #> │ Unaffiliated ┆ $50-75k ┆ 528.0 │ #> │ Unaffiliated ┆ $75-100k ┆ 407.0 │ #> │ Unaffiliated ┆ $100-150k ┆ 321.0 │ #> │ Unaffiliated ┆ >150k ┆ 258.0 │ #> │ Unaffiliated ┆ Don't know/refused ┆ 597.0 │ #> └──────────────┴────────────────────┴───────┘ pl_billboard <- polars::pl$DataFrame(tidyr::billboard) #> Warning: Passing a `data.frame` or `RPolarsDataFrame` to `pl$DataFrame()` is deprecated and will be removed in the future. Use `as_polars_df()` instead. pl_billboard #> shape: (317, 79) #> ┌──────────────────┬─────────────────────────┬──────────────┬──────┬───┬──────┬──────┬──────┬──────┐ #> │ artist ┆ track ┆ date.entered ┆ wk1 ┆ … ┆ wk73 ┆ wk74 ┆ wk75 ┆ wk76 │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ date ┆ f64 ┆ ┆ bool ┆ bool ┆ bool ┆ bool │ #> ╞══════════════════╪═════════════════════════╪══════════════╪══════╪═══╪══════╪══════╪══════╪══════╡ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 87.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 2Ge+her ┆ The Hardest Part Of ... ┆ 2000-09-02 ┆ 91.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 3 Doors Down ┆ Kryptonite ┆ 2000-04-08 ┆ 81.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 3 Doors Down ┆ Loser ┆ 2000-10-21 ┆ 76.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 504 Boyz ┆ Wobble Wobble ┆ 2000-04-15 ┆ 57.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ Yankee Grey ┆ Another Nine Minutes ┆ 2000-04-29 ┆ 86.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ Yearwood, Trisha ┆ Real Live Woman ┆ 2000-04-01 ┆ 85.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ Ying Yang Twins ┆ Whistle While You Tw... ┆ 2000-03-18 ┆ 95.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ Zombie Nation ┆ Kernkraft 400 ┆ 2000-09-02 ┆ 99.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 60.0 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> └──────────────────┴─────────────────────────┴──────────────┴──────┴───┴──────┴──────┴──────┴──────┘ pl_billboard |> pivot_longer( cols = starts_with(\"wk\"), names_to = \"week\", names_prefix = \"wk\", values_to = \"rank\", ) #> shape: (24_092, 5) #> ┌─────────────────┬─────────────────────────┬──────────────┬──────┬──────┐ #> │ artist ┆ track ┆ date.entered ┆ week ┆ rank │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ str ┆ date ┆ str ┆ f64 │ #> ╞═════════════════╪═════════════════════════╪══════════════╪══════╪══════╡ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 2 ┆ 82.0 │ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 76 ┆ null │ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 75 ┆ null │ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 74 ┆ null │ #> │ 2 Pac ┆ Baby Don't Cry (Keep... ┆ 2000-02-26 ┆ 73 ┆ null │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 32 ┆ 28.0 │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 56 ┆ null │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 17 ┆ 2.0 │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 3 ┆ 29.0 │ #> │ matchbox twenty ┆ Bent ┆ 2000-04-29 ┆ 76 ┆ null │ #> └─────────────────┴─────────────────────────┴──────────────┴──────┴──────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_wider.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","title":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","text":"Pivot DataFrame long wide","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_wider.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' pivot_wider( data, ..., id_cols = NULL, names_from = name, values_from = value, names_prefix = \"\", names_sep = \"_\", names_glue = NULL, values_fill = NULL )"},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_wider.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","text":"data Polars DataFrame (LazyFrames supported). ... Dots empty. id_cols set columns uniquely identify observation. Typically used redundant variables, .e. variables whose values perfectly correlated existing variables. Defaults columns data except columns specified names_from values_from. tidyselect expression supplied, evaluated data removing columns specified names_from values_from. names_from (quoted unquoted) column names whose values used names new columns. values_from (quoted unquoted) column names whose values used fill new columns. names_prefix String added start every variable name. particularly useful names_from numeric vector want create syntactic variable names. names_sep names_from values_from contains multiple variables, used join values together single string use column name. names_glue Instead names_sep names_prefix, can supply glue specification uses names_from columns create custom column names. values_fill scalar used replace missing values new columns. Note type value applied new columns. example, provide character value fill numeric columns, columns converted character.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_wider.RPolarsDataFrame.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pivot_wider.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Pivot a DataFrame from long to wide — pivot_wider.RPolarsDataFrame","text":"","code":"pl_fish_encounters <- polars::pl$DataFrame(tidyr::fish_encounters) #> Warning: Passing a `data.frame` or `RPolarsDataFrame` to `pl$DataFrame()` is deprecated and will be removed in the future. Use `as_polars_df()` instead. pl_fish_encounters |> pivot_wider(names_from = station, values_from = seen) #> shape: (19, 12) #> ┌──────┬─────────┬───────┬────────┬───┬──────┬──────┬──────┬──────┐ #> │ fish ┆ Release ┆ I80_1 ┆ Lisbon ┆ … ┆ BCE2 ┆ BCW2 ┆ MAE ┆ MAW │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ cat ┆ i32 ┆ i32 ┆ i32 ┆ ┆ i32 ┆ i32 ┆ i32 ┆ i32 │ #> ╞══════╪═════════╪═══════╪════════╪═══╪══════╪══════╪══════╪══════╡ #> │ 4842 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4843 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4844 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4845 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 4847 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4861 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4862 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ null ┆ null │ #> │ 4863 ┆ 1 ┆ 1 ┆ null ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 4864 ┆ 1 ┆ 1 ┆ null ┆ … ┆ null ┆ null ┆ null ┆ null │ #> │ 4865 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ null ┆ null ┆ null ┆ null │ #> └──────┴─────────┴───────┴────────┴───┴──────┴──────┴──────┴──────┘ pl_fish_encounters |> pivot_wider(names_from = station, values_from = seen, values_fill = 0) #> shape: (19, 12) #> ┌──────┬─────────┬───────┬────────┬───┬──────┬──────┬─────┬─────┐ #> │ fish ┆ Release ┆ I80_1 ┆ Lisbon ┆ … ┆ BCE2 ┆ BCW2 ┆ MAE ┆ MAW │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ cat ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════════╪═══════╪════════╪═══╪══════╪══════╪═════╪═════╡ #> │ 4842 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 4843 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 4844 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 4845 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> │ 4847 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4861 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 4862 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 0.0 ┆ 0.0 │ #> │ 4863 ┆ 1.0 ┆ 1.0 ┆ 0.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> │ 4864 ┆ 1.0 ┆ 1.0 ┆ 0.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> │ 4865 ┆ 1.0 ┆ 1.0 ┆ 1.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> └──────┴─────────┴───────┴────────┴───┴──────┴──────┴─────┴─────┘ # be careful about the type of the replacement value! pl_fish_encounters |> pivot_wider(names_from = station, values_from = seen, values_fill = \"a\") #> shape: (19, 12) #> ┌──────┬─────────┬───────┬────────┬───┬──────┬──────┬─────┬─────┐ #> │ fish ┆ Release ┆ I80_1 ┆ Lisbon ┆ … ┆ BCE2 ┆ BCW2 ┆ MAE ┆ MAW │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ cat ┆ str ┆ str ┆ str ┆ ┆ str ┆ str ┆ str ┆ str │ #> ╞══════╪═════════╪═══════╪════════╪═══╪══════╪══════╪═════╪═════╡ #> │ 4842 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4843 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4844 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4845 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ a ┆ a ┆ a ┆ a │ #> │ 4847 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ a ┆ a ┆ a ┆ a │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 4861 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ 1 ┆ 1 │ #> │ 4862 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ 1 ┆ 1 ┆ a ┆ a │ #> │ 4863 ┆ 1 ┆ 1 ┆ a ┆ … ┆ a ┆ a ┆ a ┆ a │ #> │ 4864 ┆ 1 ┆ 1 ┆ a ┆ … ┆ a ┆ a ┆ a ┆ a │ #> │ 4865 ┆ 1 ┆ 1 ┆ 1 ┆ … ┆ a ┆ a ┆ a ┆ a │ #> └──────┴─────────┴───────┴────────┴───┴──────┴──────┴─────┴─────┘ # using \"names_glue\" to specify the names of new columns production <- expand.grid( product = c(\"A\", \"B\"), country = c(\"AI\", \"EI\"), year = 2000:2014 ) |> filter((product == \"A\" & country == \"AI\") | product == \"B\") |> mutate(production = 1:45) |> as_polars_df() production #> shape: (45, 4) #> ┌─────────┬─────────┬──────┬────────────┐ #> │ product ┆ country ┆ year ┆ production │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ cat ┆ cat ┆ i32 ┆ i32 │ #> ╞═════════╪═════════╪══════╪════════════╡ #> │ A ┆ AI ┆ 2000 ┆ 1 │ #> │ B ┆ AI ┆ 2000 ┆ 2 │ #> │ B ┆ EI ┆ 2000 ┆ 3 │ #> │ A ┆ AI ┆ 2001 ┆ 4 │ #> │ B ┆ AI ┆ 2001 ┆ 5 │ #> │ … ┆ … ┆ … ┆ … │ #> │ B ┆ AI ┆ 2013 ┆ 41 │ #> │ B ┆ EI ┆ 2013 ┆ 42 │ #> │ A ┆ AI ┆ 2014 ┆ 43 │ #> │ B ┆ AI ┆ 2014 ┆ 44 │ #> │ B ┆ EI ┆ 2014 ┆ 45 │ #> └─────────┴─────────┴──────┴────────────┘ production |> pivot_wider( names_from = c(product, country), values_from = production, names_glue = \"prod_{product}_{country}\" ) #> shape: (15, 4) #> ┌──────┬───────────┬───────────┬───────────┐ #> │ year ┆ prod_A_AI ┆ prod_B_AI ┆ prod_B_EI │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ i32 ┆ i32 ┆ i32 ┆ i32 │ #> ╞══════╪═══════════╪═══════════╪═══════════╡ #> │ 2000 ┆ 1 ┆ 2 ┆ 3 │ #> │ 2001 ┆ 4 ┆ 5 ┆ 6 │ #> │ 2002 ┆ 7 ┆ 8 ┆ 9 │ #> │ 2003 ┆ 10 ┆ 11 ┆ 12 │ #> │ 2004 ┆ 13 ┆ 14 ┆ 15 │ #> │ … ┆ … ┆ … ┆ … │ #> │ 2010 ┆ 31 ┆ 32 ┆ 33 │ #> │ 2011 ┆ 34 ┆ 35 ┆ 36 │ #> │ 2012 ┆ 37 ┆ 38 ┆ 39 │ #> │ 2013 ┆ 40 ┆ 41 ┆ 42 │ #> │ 2014 ┆ 43 ┆ 44 ┆ 45 │ #> └──────┴───────────┴───────────┴───────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/pull.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract a variable of a Data/LazyFrame — pull.RPolarsDataFrame","title":"Extract a variable of a Data/LazyFrame — pull.RPolarsDataFrame","text":"returns R vector Polars Series.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pull.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract a variable of a Data/LazyFrame — pull.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' pull(.data, var, ...) # S3 method for class 'RPolarsLazyFrame' pull(.data, var, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/pull.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract a variable of a Data/LazyFrame — pull.RPolarsDataFrame","text":".data Polars Data/LazyFrame var quoted unquoted variable name, variable index. ... Dots empty.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/pull.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract a variable of a Data/LazyFrame — pull.RPolarsDataFrame","text":"","code":"pl_test <- as_polars_df(iris) pull(pl_test, Sepal.Length) #> [1] 5.1 4.9 4.7 4.6 5.0 5.4 4.6 5.0 4.4 4.9 5.4 4.8 4.8 4.3 5.8 5.7 5.4 5.1 #> [19] 5.7 5.1 5.4 5.1 4.6 5.1 4.8 5.0 5.0 5.2 5.2 4.7 4.8 5.4 5.2 5.5 4.9 5.0 #> [37] 5.5 4.9 4.4 5.1 5.0 4.5 4.4 5.0 5.1 4.8 5.1 4.6 5.3 5.0 7.0 6.4 6.9 5.5 #> [55] 6.5 5.7 6.3 4.9 6.6 5.2 5.0 5.9 6.0 6.1 5.6 6.7 5.6 5.8 6.2 5.6 5.9 6.1 #> [73] 6.3 6.1 6.4 6.6 6.8 6.7 6.0 5.7 5.5 5.5 5.8 6.0 5.4 6.0 6.7 6.3 5.6 5.5 #> [91] 5.5 6.1 5.8 5.0 5.6 5.7 5.7 6.2 5.1 5.7 6.3 5.8 7.1 6.3 6.5 7.6 4.9 7.3 #> [109] 6.7 7.2 6.5 6.4 6.8 5.7 5.8 6.4 6.5 7.7 7.7 6.0 6.9 5.6 7.7 6.3 6.7 7.2 #> [127] 6.2 6.1 6.4 7.2 7.4 7.9 6.4 6.3 6.1 7.7 6.3 6.4 6.0 6.9 6.7 6.9 5.8 6.8 #> [145] 6.7 6.7 6.3 6.5 6.2 5.9 pull(pl_test, \"Sepal.Length\") #> [1] 5.1 4.9 4.7 4.6 5.0 5.4 4.6 5.0 4.4 4.9 5.4 4.8 4.8 4.3 5.8 5.7 5.4 5.1 #> [19] 5.7 5.1 5.4 5.1 4.6 5.1 4.8 5.0 5.0 5.2 5.2 4.7 4.8 5.4 5.2 5.5 4.9 5.0 #> [37] 5.5 4.9 4.4 5.1 5.0 4.5 4.4 5.0 5.1 4.8 5.1 4.6 5.3 5.0 7.0 6.4 6.9 5.5 #> [55] 6.5 5.7 6.3 4.9 6.6 5.2 5.0 5.9 6.0 6.1 5.6 6.7 5.6 5.8 6.2 5.6 5.9 6.1 #> [73] 6.3 6.1 6.4 6.6 6.8 6.7 6.0 5.7 5.5 5.5 5.8 6.0 5.4 6.0 6.7 6.3 5.6 5.5 #> [91] 5.5 6.1 5.8 5.0 5.6 5.7 5.7 6.2 5.1 5.7 6.3 5.8 7.1 6.3 6.5 7.6 4.9 7.3 #> [109] 6.7 7.2 6.5 6.4 6.8 5.7 5.8 6.4 6.5 7.7 7.7 6.0 6.9 5.6 7.7 6.3 6.7 7.2 #> [127] 6.2 6.1 6.4 7.2 7.4 7.9 6.4 6.3 6.1 7.7 6.3 6.4 6.0 6.9 6.7 6.9 5.8 6.8 #> [145] 6.7 6.7 6.3 6.5 6.2 5.9"},{"path":"https://tidypolars.etiennebacher.com/reference/reexports.html","id":null,"dir":"Reference","previous_headings":"","what":"Objects exported from other packages — reexports","title":"Objects exported from other packages — reexports","text":"objects imported packages. Follow links see documentation. polars as_polars_df, as_polars_lf","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/relocate.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Change column order — relocate.RPolarsDataFrame","title":"Change column order — relocate.RPolarsDataFrame","text":"Use relocate() change column positions, using syntax select() make easy move blocks columns .","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/relocate.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Change column order — relocate.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' relocate(.data, ..., .before = NULL, .after = NULL) # S3 method for class 'RPolarsLazyFrame' relocate(.data, ..., .before = NULL, .after = NULL)"},{"path":"https://tidypolars.etiennebacher.com/reference/relocate.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Change column order — relocate.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. ., .Column name (either quoted unquoted) indicates destination columns selected .... Supplying neither move columns left-hand side; specifying error.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/relocate.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Change column order — relocate.RPolarsDataFrame","text":"","code":"dat <- as_polars_df(mtcars) dat |> relocate(hp, vs, .before = cyl) #> shape: (32, 11) #> ┌──────┬───────┬─────┬─────┬───┬───────┬─────┬──────┬──────┐ #> │ mpg ┆ hp ┆ vs ┆ cyl ┆ … ┆ qsec ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═══════╪═════╪═════╪═══╪═══════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 110.0 ┆ 0.0 ┆ 6.0 ┆ … ┆ 16.46 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 110.0 ┆ 0.0 ┆ 6.0 ┆ … ┆ 17.02 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 93.0 ┆ 1.0 ┆ 4.0 ┆ … ┆ 18.61 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 110.0 ┆ 1.0 ┆ 6.0 ┆ … ┆ 19.44 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 175.0 ┆ 0.0 ┆ 8.0 ┆ … ┆ 17.02 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 113.0 ┆ 1.0 ┆ 4.0 ┆ … ┆ 16.9 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 264.0 ┆ 0.0 ┆ 8.0 ┆ … ┆ 14.5 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 175.0 ┆ 0.0 ┆ 6.0 ┆ … ┆ 15.5 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 335.0 ┆ 0.0 ┆ 8.0 ┆ … ┆ 14.6 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 109.0 ┆ 1.0 ┆ 4.0 ┆ … ┆ 18.6 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴───────┴─────┴─────┴───┴───────┴─────┴──────┴──────┘ # if .before and .after are not specified, selected columns are moved to the # first positions dat |> relocate(hp, vs) #> shape: (32, 11) #> ┌───────┬─────┬──────┬─────┬───┬───────┬─────┬──────┬──────┐ #> │ hp ┆ vs ┆ mpg ┆ cyl ┆ … ┆ qsec ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═══════╪═════╪══════╪═════╪═══╪═══════╪═════╪══════╪══════╡ #> │ 110.0 ┆ 0.0 ┆ 21.0 ┆ 6.0 ┆ … ┆ 16.46 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 110.0 ┆ 0.0 ┆ 21.0 ┆ 6.0 ┆ … ┆ 17.02 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 93.0 ┆ 1.0 ┆ 22.8 ┆ 4.0 ┆ … ┆ 18.61 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 110.0 ┆ 1.0 ┆ 21.4 ┆ 6.0 ┆ … ┆ 19.44 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 175.0 ┆ 0.0 ┆ 18.7 ┆ 8.0 ┆ … ┆ 17.02 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 113.0 ┆ 1.0 ┆ 30.4 ┆ 4.0 ┆ … ┆ 16.9 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 264.0 ┆ 0.0 ┆ 15.8 ┆ 8.0 ┆ … ┆ 14.5 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 175.0 ┆ 0.0 ┆ 19.7 ┆ 6.0 ┆ … ┆ 15.5 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 335.0 ┆ 0.0 ┆ 15.0 ┆ 8.0 ┆ … ┆ 14.6 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 109.0 ┆ 1.0 ┆ 21.4 ┆ 4.0 ┆ … ┆ 18.6 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └───────┴─────┴──────┴─────┴───┴───────┴─────┴──────┴──────┘ # .before and .after can be quoted or unquoted dat |> relocate(hp, vs, .after = \"gear\") #> shape: (32, 11) #> ┌──────┬─────┬───────┬──────┬───┬──────┬───────┬─────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ drat ┆ … ┆ gear ┆ hp ┆ vs ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪══════╪═══╪══════╪═══════╪═════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 3.9 ┆ … ┆ 4.0 ┆ 110.0 ┆ 0.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 3.9 ┆ … ┆ 4.0 ┆ 110.0 ┆ 0.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 3.85 ┆ … ┆ 4.0 ┆ 93.0 ┆ 1.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 3.08 ┆ … ┆ 3.0 ┆ 110.0 ┆ 1.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 3.15 ┆ … ┆ 3.0 ┆ 175.0 ┆ 0.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 3.77 ┆ … ┆ 5.0 ┆ 113.0 ┆ 1.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 4.22 ┆ … ┆ 5.0 ┆ 264.0 ┆ 0.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 3.62 ┆ … ┆ 5.0 ┆ 175.0 ┆ 0.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 3.54 ┆ … ┆ 5.0 ┆ 335.0 ┆ 0.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 4.11 ┆ … ┆ 4.0 ┆ 109.0 ┆ 1.0 ┆ 2.0 │ #> └──────┴─────┴───────┴──────┴───┴──────┴───────┴─────┴──────┘ # select helpers are also available dat |> relocate(contains(\"[aeiou]\")) #> shape: (32, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘ dat |> relocate(hp, vs, .after = last_col()) #> shape: (32, 11) #> ┌──────┬─────┬───────┬──────┬───┬──────┬──────┬───────┬─────┐ #> │ mpg ┆ cyl ┆ disp ┆ drat ┆ … ┆ gear ┆ carb ┆ hp ┆ vs │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪══════╪═══╪══════╪══════╪═══════╪═════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 3.9 ┆ … ┆ 4.0 ┆ 4.0 ┆ 110.0 ┆ 0.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 3.9 ┆ … ┆ 4.0 ┆ 4.0 ┆ 110.0 ┆ 0.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 3.85 ┆ … ┆ 4.0 ┆ 1.0 ┆ 93.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 3.08 ┆ … ┆ 3.0 ┆ 1.0 ┆ 110.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 3.15 ┆ … ┆ 3.0 ┆ 2.0 ┆ 175.0 ┆ 0.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 3.77 ┆ … ┆ 5.0 ┆ 2.0 ┆ 113.0 ┆ 1.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 4.22 ┆ … ┆ 5.0 ┆ 4.0 ┆ 264.0 ┆ 0.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 3.62 ┆ … ┆ 5.0 ┆ 6.0 ┆ 175.0 ┆ 0.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 3.54 ┆ … ┆ 5.0 ┆ 8.0 ┆ 335.0 ┆ 0.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 4.11 ┆ … ┆ 4.0 ┆ 2.0 ┆ 109.0 ┆ 1.0 │ #> └──────┴─────┴───────┴──────┴───┴──────┴──────┴───────┴─────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/rename.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Rename columns — rename.RPolarsDataFrame","title":"Rename columns — rename.RPolarsDataFrame","text":"Rename columns","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/rename.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rename columns — rename.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' rename(.data, ...) # S3 method for class 'RPolarsLazyFrame' rename(.data, ...) # S3 method for class 'RPolarsDataFrame' rename_with(.data, .fn, .cols = tidyselect::everything(), ...) # S3 method for class 'RPolarsLazyFrame' rename_with(.data, .fn, .cols = tidyselect::everything(), ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/rename.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Rename columns — rename.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... rename(), use new_name = old_name rename selected variables. also possible use quotation marks, e.g \"new_name\" = \"old_name\". rename_with, additional arguments passed fn. .fn Function apply column names .cols Columns apply fn. Can anything accepted dplyr::select().","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/rename.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rename columns — rename.RPolarsDataFrame","text":"","code":"pl_test <- polars::as_polars_df(mtcars) rename(pl_test, miles_per_gallon = mpg, horsepower = \"hp\") #> shape: (32, 11) #> ┌──────────────────┬─────┬───────┬────────────┬───┬─────┬─────┬──────┬──────┐ #> │ miles_per_gallon ┆ cyl ┆ disp ┆ horsepower ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════════════════╪═════╪═══════╪════════════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────────────────┴─────┴───────┴────────────┴───┴─────┴─────┴──────┴──────┘ rename(pl_test, `Miles per gallon` = \"mpg\", `Horse power` = \"hp\") #> shape: (32, 11) #> ┌──────────────────┬─────┬───────┬─────────────┬───┬─────┬─────┬──────┬──────┐ #> │ Miles per gallon ┆ cyl ┆ disp ┆ Horse power ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════════════════╪═════╪═══════╪═════════════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────────────────┴─────┴───────┴─────────────┴───┴─────┴─────┴──────┴──────┘ rename_with(pl_test, toupper, .cols = contains(\"p\")) #> shape: (32, 11) #> ┌──────┬─────┬───────┬───────┬───┬─────┬─────┬──────┬──────┐ #> │ MPG ┆ cyl ┆ DISP ┆ HP ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞══════╪═════╪═══════╪═══════╪═══╪═════╪═════╪══════╪══════╡ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 1.0 │ #> │ 21.4 ┆ 6.0 ┆ 258.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ 18.7 ┆ 8.0 ┆ 360.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 30.4 ┆ 4.0 ┆ 95.1 ┆ 113.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 2.0 │ #> │ 15.8 ┆ 8.0 ┆ 351.0 ┆ 264.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 4.0 │ #> │ 19.7 ┆ 6.0 ┆ 145.0 ┆ 175.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 6.0 │ #> │ 15.0 ┆ 8.0 ┆ 301.0 ┆ 335.0 ┆ … ┆ 0.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> │ 21.4 ┆ 4.0 ┆ 121.0 ┆ 109.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 2.0 │ #> └──────┴─────┴───────┴───────┴───┴─────┴─────┴──────┴──────┘ pl_test_2 <- polars::as_polars_df(iris) rename_with(pl_test_2, function(x) tolower(gsub(\".\", \"_\", x, fixed = TRUE))) #> shape: (150, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ sepal_length ┆ sepal_width ┆ petal_length ┆ petal_width ┆ species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ rename_with(pl_test_2, \\(x) tolower(gsub(\".\", \"_\", x, fixed = TRUE))) #> shape: (150, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ sepal_length ┆ sepal_width ┆ petal_length ┆ petal_width ┆ species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> │ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ setosa │ #> │ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ virginica │ #> │ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ virginica │ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/replace_na.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Replace NAs with specified values — replace_na.RPolarsDataFrame","title":"Replace NAs with specified values — replace_na.RPolarsDataFrame","text":"Replace NAs specified values","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/replace_na.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Replace NAs with specified values — replace_na.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' replace_na(data, replace, ...) # S3 method for class 'RPolarsLazyFrame' replace_na(data, replace, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/replace_na.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Replace NAs with specified values — replace_na.RPolarsDataFrame","text":"data Polars Data/LazyFrame replace Either scalar used replace NA columns, named list column name value used replace NA . ... Dots empty.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/replace_na.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Replace NAs with specified values — replace_na.RPolarsDataFrame","text":"","code":"pl_test <- polars::pl$DataFrame(x = c(NA, 1), y = c(2, NA)) # replace all NA with 0 replace_na(pl_test, 0) #> shape: (2, 2) #> ┌─────┬─────┐ #> │ x ┆ y │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞═════╪═════╡ #> │ 0.0 ┆ 2.0 │ #> │ 1.0 ┆ 0.0 │ #> └─────┴─────┘ # custom replacement per column replace_na(pl_test, list(x = 0, y = 999)) #> shape: (2, 2) #> ┌─────┬───────┐ #> │ x ┆ y │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞═════╪═══════╡ #> │ 0.0 ┆ 2.0 │ #> │ 1.0 ┆ 999.0 │ #> └─────┴───────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/rowwise.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Group input by rows — rowwise.RPolarsDataFrame","title":"Group input by rows — rowwise.RPolarsDataFrame","text":"[EXPERIMENTAL] rowwise() allows compute Data/LazyFrame row---time. useful vectorised function exist. rowwise() produces another type grouped data, therefore can removed ungroup().","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/rowwise.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Group input by rows — rowwise.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' rowwise(data, ...) # S3 method for class 'RPolarsLazyFrame' rowwise(data, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/rowwise.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Group input by rows — rowwise.RPolarsDataFrame","text":"data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/rowwise.RPolarsDataFrame.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Group input by rows — rowwise.RPolarsDataFrame","text":"Polars Data/LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/rowwise.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Group input by rows — rowwise.RPolarsDataFrame","text":"","code":"df <- polars::pl$DataFrame(x = c(1, 3, 4), y = c(2, 1, 5), z = c(2, 3, 1)) # Compute the mean of x, y, z in each row df |> rowwise() |> mutate(m = mean(c(x, y, z))) #> shape: (3, 4) #> ┌─────┬─────┬─────┬──────────┐ #> │ x ┆ y ┆ z ┆ m │ #> │ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╪══════════╡ #> │ 1.0 ┆ 2.0 ┆ 2.0 ┆ 1.666667 │ #> │ 3.0 ┆ 1.0 ┆ 3.0 ┆ 2.333333 │ #> │ 4.0 ┆ 5.0 ┆ 1.0 ┆ 3.333333 │ #> └─────┴─────┴─────┴──────────┘ #> #> Rowwise: TRUE # Compute the min and max of x and y in each row df |> rowwise() |> mutate(min = min(c(x, y)), max = max(c(x, y))) #> shape: (3, 5) #> ┌─────┬─────┬─────┬─────┬─────┐ #> │ x ┆ y ┆ z ┆ min ┆ max │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╪═════╪═════╡ #> │ 1.0 ┆ 2.0 ┆ 2.0 ┆ 1.0 ┆ 2.0 │ #> │ 3.0 ┆ 1.0 ┆ 3.0 ┆ 1.0 ┆ 3.0 │ #> │ 4.0 ┆ 5.0 ┆ 1.0 ┆ 4.0 ┆ 5.0 │ #> └─────┴─────┴─────┴─────┴─────┘ #> #> Rowwise: TRUE"},{"path":"https://tidypolars.etiennebacher.com/reference/select.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Select columns from a Data/LazyFrame — select.RPolarsDataFrame","title":"Select columns from a Data/LazyFrame — select.RPolarsDataFrame","text":"Select columns Data/LazyFrame","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/select.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select columns from a Data/LazyFrame — select.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' select(.data, ...) # S3 method for class 'RPolarsLazyFrame' select(.data, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/select.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select columns from a Data/LazyFrame — select.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. Renaming also possible.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/select.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select columns from a Data/LazyFrame — select.RPolarsDataFrame","text":"","code":"pl_iris <- polars::as_polars_df(iris) select(pl_iris, c(\"Sepal.Length\", \"Sepal.Width\")) #> shape: (150, 2) #> ┌──────────────┬─────────────┐ #> │ Sepal.Length ┆ Sepal.Width │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════════════╪═════════════╡ #> │ 5.1 ┆ 3.5 │ #> │ 4.9 ┆ 3.0 │ #> │ 4.7 ┆ 3.2 │ #> │ 4.6 ┆ 3.1 │ #> │ 5.0 ┆ 3.6 │ #> │ … ┆ … │ #> │ 6.7 ┆ 3.0 │ #> │ 6.3 ┆ 2.5 │ #> │ 6.5 ┆ 3.0 │ #> │ 6.2 ┆ 3.4 │ #> │ 5.9 ┆ 3.0 │ #> └──────────────┴─────────────┘ select(pl_iris, Sepal.Length, Sepal.Width) #> shape: (150, 2) #> ┌──────────────┬─────────────┐ #> │ Sepal.Length ┆ Sepal.Width │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════════════╪═════════════╡ #> │ 5.1 ┆ 3.5 │ #> │ 4.9 ┆ 3.0 │ #> │ 4.7 ┆ 3.2 │ #> │ 4.6 ┆ 3.1 │ #> │ 5.0 ┆ 3.6 │ #> │ … ┆ … │ #> │ 6.7 ┆ 3.0 │ #> │ 6.3 ┆ 2.5 │ #> │ 6.5 ┆ 3.0 │ #> │ 6.2 ┆ 3.4 │ #> │ 5.9 ┆ 3.0 │ #> └──────────────┴─────────────┘ select(pl_iris, 1:3) #> shape: (150, 3) #> ┌──────────────┬─────────────┬──────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞══════════════╪═════════════╪══════════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 │ #> │ 4.9 ┆ 3.0 ┆ 1.4 │ #> │ 4.7 ┆ 3.2 ┆ 1.3 │ #> │ 4.6 ┆ 3.1 ┆ 1.5 │ #> │ 5.0 ┆ 3.6 ┆ 1.4 │ #> │ … ┆ … ┆ … │ #> │ 6.7 ┆ 3.0 ┆ 5.2 │ #> │ 6.3 ┆ 2.5 ┆ 5.0 │ #> │ 6.5 ┆ 3.0 ┆ 5.2 │ #> │ 6.2 ┆ 3.4 ┆ 5.4 │ #> │ 5.9 ┆ 3.0 ┆ 5.1 │ #> └──────────────┴─────────────┴──────────────┘ select(pl_iris, starts_with(\"Sepal\")) #> shape: (150, 2) #> ┌──────────────┬─────────────┐ #> │ Sepal.Length ┆ Sepal.Width │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════════════╪═════════════╡ #> │ 5.1 ┆ 3.5 │ #> │ 4.9 ┆ 3.0 │ #> │ 4.7 ┆ 3.2 │ #> │ 4.6 ┆ 3.1 │ #> │ 5.0 ┆ 3.6 │ #> │ … ┆ … │ #> │ 6.7 ┆ 3.0 │ #> │ 6.3 ┆ 2.5 │ #> │ 6.5 ┆ 3.0 │ #> │ 6.2 ┆ 3.4 │ #> │ 5.9 ┆ 3.0 │ #> └──────────────┴─────────────┘ select(pl_iris, -ends_with(\"Length\")) #> shape: (150, 3) #> ┌─────────────┬─────────────┬───────────┐ #> │ Sepal.Width ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ cat │ #> ╞═════════════╪═════════════╪═══════════╡ #> │ 3.5 ┆ 0.2 ┆ setosa │ #> │ 3.0 ┆ 0.2 ┆ setosa │ #> │ 3.2 ┆ 0.2 ┆ setosa │ #> │ 3.1 ┆ 0.2 ┆ setosa │ #> │ 3.6 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … │ #> │ 3.0 ┆ 2.3 ┆ virginica │ #> │ 2.5 ┆ 1.9 ┆ virginica │ #> │ 3.0 ┆ 2.0 ┆ virginica │ #> │ 3.4 ┆ 2.3 ┆ virginica │ #> │ 3.0 ┆ 1.8 ┆ virginica │ #> └─────────────┴─────────────┴───────────┘ # Renaming while selecting is also possible select(pl_iris, foo1 = Sepal.Length, Sepal.Width) #> shape: (150, 2) #> ┌──────┬─────────────┐ #> │ foo1 ┆ Sepal.Width │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞══════╪═════════════╡ #> │ 5.1 ┆ 3.5 │ #> │ 4.9 ┆ 3.0 │ #> │ 4.7 ┆ 3.2 │ #> │ 4.6 ┆ 3.1 │ #> │ 5.0 ┆ 3.6 │ #> │ … ┆ … │ #> │ 6.7 ┆ 3.0 │ #> │ 6.3 ┆ 2.5 │ #> │ 6.5 ┆ 3.0 │ #> │ 6.2 ┆ 3.4 │ #> │ 5.9 ┆ 3.0 │ #> └──────┴─────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/semi_join.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Filtering joins — semi_join.RPolarsDataFrame","title":"Filtering joins — semi_join.RPolarsDataFrame","text":"Filtering joins filter rows x based presence absence matches y: semi_join() return rows x match y. anti_join() return rows x without match y.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/semi_join.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filtering joins — semi_join.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' semi_join(x, y, by = NULL, ..., na_matches = \"na\") # S3 method for class 'RPolarsDataFrame' anti_join(x, y, by = NULL, ..., na_matches = \"na\") # S3 method for class 'RPolarsLazyFrame' semi_join(x, y, by = NULL, ..., na_matches = \"na\") # S3 method for class 'RPolarsLazyFrame' anti_join(x, y, by = NULL, ..., na_matches = \"na\")"},{"path":"https://tidypolars.etiennebacher.com/reference/semi_join.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filtering joins — semi_join.RPolarsDataFrame","text":"x, y Two Polars Data/LazyFrames Variables join . NULL (default), *_join() perform natural join, using variables common across x y. message lists variables can check correct; suppress message supplying explicitly. can take character vector, like c(\"x\", \"y\") x y datasets. join variables name, use equalities character vector, like c(\"x1\" = \"x2\", \"y\"). use character vector, join can done using strict equality. can also specification created dplyr::join_by(). Contrary input character vector shown , join_by() uses unquoted column names, e.g join_by(x1 == x2, y). Finally, inner_join() also supports inequality joins, e.g. join_by(x1 >= x2), helpers (), overlaps(), within(). See documentation dplyr::join_by() information. join types likely support inequality joins future. ... Dots empty. na_matches two NA values match? \"na\", default, treats two NA values equal. \"never\" treats two NA values different never match together values. Note joining Polars Data/LazyFrames, NaN always considered equal, matter value na_matches. differs original dplyr implementation.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/semi_join.RPolarsDataFrame.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Filtering joins — semi_join.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/semi_join.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Filtering joins — semi_join.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame( x = c(1, 2, 3), y = c(1, 2, 3), z = c(1, 2, 3) ) test2 <- polars::pl$DataFrame( x = c(1, 2, 4), y = c(1, 2, 4), z2 = c(1, 2, 4) ) test #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 │ #> │ 3.0 ┆ 3.0 ┆ 3.0 │ #> └─────┴─────┴─────┘ test2 #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ z2 │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 │ #> │ 4.0 ┆ 4.0 ┆ 4.0 │ #> └─────┴─────┴─────┘ # only keep the rows of `test` that have matching keys in `test2` semi_join(test, test2, by = c(\"x\", \"y\")) #> shape: (2, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 1.0 ┆ 1.0 ┆ 1.0 │ #> │ 2.0 ┆ 2.0 ┆ 2.0 │ #> └─────┴─────┴─────┘ # only keep the rows of `test` that don't have matching keys in `test2` anti_join(test, test2, by = c(\"x\", \"y\")) #> shape: (1, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ z │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ 3.0 ┆ 3.0 ┆ 3.0 │ #> └─────┴─────┴─────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/separate.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Separate a character column into multiple columns based on a substring — separate.RPolarsDataFrame","title":"Separate a character column into multiple columns based on a substring — separate.RPolarsDataFrame","text":"Currently, splitting column regular expression position possible.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/separate.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Separate a character column into multiple columns based on a substring — separate.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' separate(data, col, into, sep = \" \", remove = TRUE, ...) # S3 method for class 'RPolarsLazyFrame' separate(data, col, into, sep = \" \", remove = TRUE, ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/separate.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Separate a character column into multiple columns based on a substring — separate.RPolarsDataFrame","text":"data Polars Data/LazyFrame col Column split Character vector containing names new variables create. Use NA omit variable output. sep String used split column. Regular expressions supported yet. remove TRUE, remove input column output data frame. ... Dots empty.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/separate.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Separate a character column into multiple columns based on a substring — separate.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame( x = c(NA, \"x.y\", \"x.z\", \"y.z\") ) separate(test, x, into = c(\"foo\", \"foo2\"), sep = \".\") #> shape: (4, 2) #> ┌──────┬──────┐ #> │ foo ┆ foo2 │ #> │ --- ┆ --- │ #> │ str ┆ str │ #> ╞══════╪══════╡ #> │ null ┆ null │ #> │ x ┆ y │ #> │ x ┆ z │ #> │ y ┆ z │ #> └──────┴──────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_csv.html","id":null,"dir":"Reference","previous_headings":"","what":"Stream output to a CSV file — sink_csv","title":"Stream output to a CSV file — sink_csv","text":"function allows stream LazyFrame larger RAM directly .csv file without collecting R session, thus preventing crashes small memory.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_csv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stream output to a CSV file — sink_csv","text":"","code":"sink_csv( .data, path, ..., include_bom = FALSE, include_header = TRUE, separator = \",\", line_terminator = \"\\n\", quote = \"\\\"\", batch_size = 1024, datetime_format = NULL, date_format = NULL, time_format = NULL, float_precision = NULL, null_values = \"\", quote_style = \"necessary\", maintain_order = TRUE, type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, no_optimization = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_csv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stream output to a CSV file — sink_csv","text":".data Polars LazyFrame. path Output file (must .csv file). ... Ignored. include_bom Whether include UTF-8 BOM (byte order mark) CSV output. include_header Whether include header CSV output. separator Separate CSV fields symbol. line_terminator String used end row. quote Byte use quoting character. batch_size Number rows processed per thread. datetime_format, date_format, time_format format string used format date time values. See ?strptime() accepted values. format specified, default fractional-second precision inferred maximum time unit found Datetime cols (). float_precision Number decimal places write, applied Float32 Float64 datatypes. null_values string representing null values (defaulting empty string). quote_style Determines quoting strategy used: \"necessary\" (default): puts quotes around fields necessary. necessary fields contain quote, delimiter record terminator. Quotes also necessary writing empty record (indistinguishable record one empty field). \"always\": puts quotes around every field. \"non_numeric\": puts quotes around fields non-numeric. Namely, writing field parse valid float integer, quotes used even strictly necessary. maintain_order Whether maintain order data processed (default TRUE). Setting FALSE slightly faster. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_csv.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Stream output to a CSV file — sink_csv","text":"input LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_csv.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Stream output to a CSV file — sink_csv","text":"","code":"if (FALSE) { # \\dontrun{ # This is an example workflow where sink_csv() is not very useful because # the data would fit in memory. It simply is an example of using it at the # end of a piped workflow. # Create files for the CSV input and output: file_csv <- tempfile(fileext = \".csv\") file_csv2 <- tempfile(fileext = \".csv\") # Write some data in a CSV file fake_data <- do.call(\"rbind\", rep(list(mtcars), 1000)) write.csv(fake_data, file = file_csv, row.names = FALSE) # In a new R session, we could read this file as a LazyFrame, do some operations, # and write it to another CSV file without ever collecting it in the R session: scan_csv_polars(file_csv) |> filter(cyl %in% c(4, 6), mpg > 22) |> mutate( hp_gear_ratio = hp / gear ) |> sink_csv(path = file_csv2) } # }"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ipc.html","id":null,"dir":"Reference","previous_headings":"","what":"Stream output to an IPC file — sink_ipc","title":"Stream output to an IPC file — sink_ipc","text":"function allows stream LazyFrame larger RAM directly IPC file without collecting R session, thus preventing crashes small memory.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ipc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stream output to an IPC file — sink_ipc","text":"","code":"sink_ipc( .data, path, ..., compression = \"zstd\", maintain_order = TRUE, type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, no_optimization = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ipc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stream output to an IPC file — sink_ipc","text":".data Polars LazyFrame. path Output file. ... Ignored. compression NULL character compression method, \"uncompressed\" \"lz4\" \"zstd\". NULL equivalent \"uncompressed\". Choose \"zstd\" good compression performance. Choose \"lz4\" fast compression/decompression. maintain_order Whether maintain order data processed (default TRUE). Setting FALSE slightly faster. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ipc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Stream output to an IPC file — sink_ipc","text":"input LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ndjson.html","id":null,"dir":"Reference","previous_headings":"","what":"Stream output to a NDJSON file — sink_ndjson","title":"Stream output to a NDJSON file — sink_ndjson","text":"writes output query directly NDJSON file without collecting R session first. useful output query still larger RAM crash R session collected R.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ndjson.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stream output to a NDJSON file — sink_ndjson","text":"","code":"sink_ndjson( .data, path, ..., maintain_order = TRUE, type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, no_optimization = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ndjson.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stream output to a NDJSON file — sink_ndjson","text":".data Polars LazyFrame. path Output file. ... Ignored. maintain_order Whether maintain order data processed (default TRUE). Setting FALSE slightly faster. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_ndjson.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Stream output to a NDJSON file — sink_ndjson","text":"input LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_parquet.html","id":null,"dir":"Reference","previous_headings":"","what":"Stream output to a parquet file — sink_parquet","title":"Stream output to a parquet file — sink_parquet","text":"function allows stream LazyFrame larger RAM directly .parquet file without collecting R session, thus preventing crashes small memory.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_parquet.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Stream output to a parquet file — sink_parquet","text":"","code":"sink_parquet( .data, path, ..., compression = \"zstd\", compression_level = 3, statistics = FALSE, row_group_size = NULL, data_page_size = NULL, maintain_order = TRUE, type_coercion = TRUE, predicate_pushdown = TRUE, projection_pushdown = TRUE, simplify_expression = TRUE, slice_pushdown = TRUE, no_optimization = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/sink_parquet.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Stream output to a parquet file — sink_parquet","text":".data Polars LazyFrame. path Output file (must .parquet file). ... Ignored. compression compression method. One : \"uncompressed\" \"zstd\" (default): good compression performance \"lz4\": fast compression / decompression \"snappy\": backwards compatibility guarantees deal older parquet readers. \"gzip\", \"lzo\", \"brotli\" compression_level level compression use (default 3). used compression one \"gzip\", \"brotli\", \"zstd\". Higher compression means smaller files disk. \"gzip\" : min-level = 0, max-level = 10 \"brotli\" : min-level = 0, max-level = 11 \"zstd\" : min-level = 1, max-level = 22. statistics Whether compute write column statistics (default FALSE). requires computations. row_group_size Size row groups number rows. NULL (default), chunks DataFrame used. Writing smaller chunks may reduce memory pressure improve writing speeds. data_page_size NULL (default), limit around 1MB. maintain_order Whether maintain order data processed (default TRUE). Setting FALSE slightly faster. type_coercion Coerce types operations succeed run minimal required memory (default TRUE). predicate_pushdown Applies filters early possible scan level (default TRUE). projection_pushdown Select columns needed scan level (default TRUE). simplify_expression Various optimizations, constant folding replacing expensive operations faster alternatives (default TRUE). slice_pushdown load required slice scan. materialize sliced outputs level. materialize sliced outputs (default TRUE). no_optimization Sets following optimizations FALSE: predicate_pushdown, projection_pushdown, slice_pushdown, simplify_expression. Default FALSE.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_parquet.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Stream output to a parquet file — sink_parquet","text":"input LazyFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/sink_parquet.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Stream output to a parquet file — sink_parquet","text":"","code":"if (FALSE) { # \\dontrun{ # This is an example workflow where sink_parquet() is not very useful because # the data would fit in memory. It simply is an example of using it at the # end of a piped workflow. # Create files for the CSV input and the Parquet output: file_csv <- tempfile(fileext = \".csv\") file_parquet <- tempfile(fileext = \".parquet\") # Write some data in a CSV file fake_data <- do.call(\"rbind\", rep(list(mtcars), 1000)) write.csv(fake_data, file = file_csv, row.names = FALSE) # In a new R session, we could read this file as a LazyFrame, do some operations, # and write it to a parquet file without ever collecting it in the R session: scan_csv_polars(file_csv) |> filter(cyl %in% c(4, 6), mpg > 22) |> mutate( hp_gear_ratio = hp / gear ) |> sink_parquet(path = file_parquet) } # }"},{"path":"https://tidypolars.etiennebacher.com/reference/slice_tail.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","title":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","text":"Subset rows Data/LazyFrame","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/slice_tail.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' slice_tail(.data, ..., n, by = NULL) # S3 method for class 'RPolarsLazyFrame' slice_tail(.data, ..., n, by = NULL) # S3 method for class 'RPolarsDataFrame' slice_head(.data, ..., n, by = NULL) # S3 method for class 'RPolarsLazyFrame' slice_head(.data, ..., n, by = NULL) # S3 method for class 'RPolarsDataFrame' slice_sample(.data, ..., n = NULL, prop = NULL, by = NULL, replace = FALSE)"},{"path":"https://tidypolars.etiennebacher.com/reference/slice_tail.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Dots empty. n number rows select start end data. used prop. Optionally, selection columns group just operation, functioning alternative group_by(). group order maintained, use group_by() want control . prop Proportion rows select. used n. replace Perform sampling replacement (TRUE) without (FALSE).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/slice_tail.RPolarsDataFrame.html","id":"unknown-arguments","dir":"Reference","previous_headings":"","what":"Unknown arguments","title":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","text":"Arguments supported original implementation tidyverse listed throw warning default specified. change behavior error instead, use options(tidypolars_unknown_args = \"error\").","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/slice_tail.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subset rows of a Data/LazyFrame — slice_tail.RPolarsDataFrame","text":"","code":"pl_test <- polars::as_polars_df(iris) slice_head(pl_test, n = 3) #> shape: (3, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬─────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═════════╡ #> │ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ setosa │ #> │ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴─────────┘ slice_tail(pl_test, n = 3) #> shape: (3, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬───────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪═══════════╡ #> │ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ virginica │ #> │ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ virginica │ #> │ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ virginica │ #> └──────────────┴─────────────┴──────────────┴─────────────┴───────────┘ slice_sample(pl_test, n = 5) #> shape: (5, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪════════════╡ #> │ 6.4 ┆ 2.8 ┆ 5.6 ┆ 2.2 ┆ virginica │ #> │ 5.0 ┆ 3.4 ┆ 1.6 ┆ 0.4 ┆ setosa │ #> │ 6.0 ┆ 2.7 ┆ 5.1 ┆ 1.6 ┆ versicolor │ #> │ 6.2 ┆ 2.8 ┆ 4.8 ┆ 1.8 ┆ virginica │ #> │ 5.4 ┆ 3.9 ┆ 1.7 ┆ 0.4 ┆ setosa │ #> └──────────────┴─────────────┴──────────────┴─────────────┴────────────┘ slice_sample(pl_test, prop = 0.1) #> shape: (15, 5) #> ┌──────────────┬─────────────┬──────────────┬─────────────┬────────────┐ #> │ Sepal.Length ┆ Sepal.Width ┆ Petal.Length ┆ Petal.Width ┆ Species │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ cat │ #> ╞══════════════╪═════════════╪══════════════╪═════════════╪════════════╡ #> │ 4.7 ┆ 3.2 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 5.6 ┆ 2.9 ┆ 3.6 ┆ 1.3 ┆ versicolor │ #> │ 6.6 ┆ 2.9 ┆ 4.6 ┆ 1.3 ┆ versicolor │ #> │ 5.0 ┆ 3.5 ┆ 1.6 ┆ 0.6 ┆ setosa │ #> │ 5.8 ┆ 4.0 ┆ 1.2 ┆ 0.2 ┆ setosa │ #> │ … ┆ … ┆ … ┆ … ┆ … │ #> │ 5.0 ┆ 3.0 ┆ 1.6 ┆ 0.2 ┆ setosa │ #> │ 7.7 ┆ 2.8 ┆ 6.7 ┆ 2.0 ┆ virginica │ #> │ 6.7 ┆ 3.1 ┆ 4.7 ┆ 1.5 ┆ versicolor │ #> │ 6.7 ┆ 3.1 ┆ 4.4 ┆ 1.4 ┆ versicolor │ #> │ 6.4 ┆ 3.2 ┆ 4.5 ┆ 1.5 ┆ versicolor │ #> └──────────────┴─────────────┴──────────────┴─────────────┴────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/summarize.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize each group down to one row — summarize.RPolarsDataFrame","title":"Summarize each group down to one row — summarize.RPolarsDataFrame","text":"summarize() returns one row combination grouping variables (one difference dplyr::summarize() summarize() accepts grouped data). contain one column grouping variable one column summary statistics specified.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/summarize.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize each group down to one row — summarize.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' summarize(.data, ..., .by = NULL, .groups = \"drop_last\") # S3 method for class 'RPolarsDataFrame' summarise(.data, ..., .by = NULL, .groups = \"drop_last\") # S3 method for class 'RPolarsLazyFrame' summarize(.data, ..., .by = NULL, .groups = \"drop_last\") # S3 method for class 'RPolarsLazyFrame' summarise(.data, ..., .by = NULL, .groups = \"drop_last\")"},{"path":"https://tidypolars.etiennebacher.com/reference/summarize.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize each group down to one row — summarize.RPolarsDataFrame","text":".data Polars Data/LazyFrame ... Name-value pairs. name gives name column output. value can : vector length current group (whole data frame ungrouped). NULL, remove column. across() mostly supported, except cases. particular, .cols argument (...), select variables created across(). select helpers supported. See examples. .Optionally, selection columns group just operation, functioning alternative group_by(). group order maintained, use group_by() want control . .groups Grouping structure result. Must one : \"drop_last\" (default): drop last level grouping; \"drop\": levels grouping dropped; \"keep\": keep grouping structure .data. now, \"rowwise\" supported. Note dplyr uses .groups = NULL default, whose behavior depends number rows group output. However, returning several rows group summarize() deprecated (one use reframe() instead), .groups = NULL supported tidypolars.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/summarize.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarize each group down to one row — summarize.RPolarsDataFrame","text":"","code":"mtcars |> as_polars_df() |> group_by(cyl) |> summarize(m_gear = mean(gear), sd_gear = sd(gear)) #> shape: (3, 3) #> ┌─────┬──────────┬──────────┐ #> │ cyl ┆ m_gear ┆ sd_gear │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪══════════╪══════════╡ #> │ 6.0 ┆ 3.857143 ┆ 0.690066 │ #> │ 4.0 ┆ 4.090909 ┆ 0.53936 │ #> │ 8.0 ┆ 3.285714 ┆ 0.726273 │ #> └─────┴──────────┴──────────┘ # an alternative syntax is to use `.by` mtcars |> as_polars_df() |> summarize(m_gear = mean(gear), sd_gear = sd(gear), .by = cyl) #> shape: (3, 3) #> ┌─────┬──────────┬──────────┐ #> │ cyl ┆ m_gear ┆ sd_gear │ #> │ --- ┆ --- ┆ --- │ #> │ f64 ┆ f64 ┆ f64 │ #> ╞═════╪══════════╪══════════╡ #> │ 8.0 ┆ 3.285714 ┆ 0.726273 │ #> │ 4.0 ┆ 4.090909 ┆ 0.53936 │ #> │ 6.0 ┆ 3.857143 ┆ 0.690066 │ #> └─────┴──────────┴──────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/summary.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Summary statistics for a Polars DataFrame — summary.RPolarsDataFrame","title":"Summary statistics for a Polars DataFrame — summary.RPolarsDataFrame","text":"Summary statistics Polars DataFrame","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/summary.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summary statistics for a Polars DataFrame — summary.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' summary(object, percentiles = c(0.25, 0.75), ...)"},{"path":"https://tidypolars.etiennebacher.com/reference/summary.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summary statistics for a Polars DataFrame — summary.RPolarsDataFrame","text":"object Polars DataFrame. percentiles One percentiles include summary statistics. values must 0 1 (NULL ignored). ... Ignored.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/summary.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summary statistics for a Polars DataFrame — summary.RPolarsDataFrame","text":"","code":"mtcars |> as_polars_df() |> summary(percentiles = c(0.2, 0.4, 0.6, 0.8)) #> shape: (11, 12) #> ┌────────────┬───────────┬──────────┬────────────┬───┬──────────┬──────────┬──────────┬────────┐ #> │ statistic ┆ mpg ┆ cyl ┆ disp ┆ … ┆ vs ┆ am ┆ gear ┆ carb │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ str ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ #> ╞════════════╪═══════════╪══════════╪════════════╪═══╪══════════╪══════════╪══════════╪════════╡ #> │ count ┆ 32.0 ┆ 32.0 ┆ 32.0 ┆ … ┆ 32.0 ┆ 32.0 ┆ 32.0 ┆ 32.0 │ #> │ null_count ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │ #> │ mean ┆ 20.090625 ┆ 6.1875 ┆ 230.721875 ┆ … ┆ 0.4375 ┆ 0.40625 ┆ 3.6875 ┆ 2.8125 │ #> │ std ┆ 6.026948 ┆ 1.785922 ┆ 123.938694 ┆ … ┆ 0.504016 ┆ 0.498991 ┆ 0.737804 ┆ 1.6152 │ #> │ min ┆ 10.4 ┆ 4.0 ┆ 71.1 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 1.0 │ #> │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ #> │ 40% ┆ 17.8 ┆ 6.0 ┆ 160.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 3.0 ┆ 2.0 │ #> │ 50% ┆ 19.2 ┆ 6.0 ┆ 225.0 ┆ … ┆ 0.0 ┆ 0.0 ┆ 4.0 ┆ 2.0 │ #> │ 60% ┆ 21.0 ┆ 8.0 ┆ 275.8 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 3.0 │ #> │ 80% ┆ 24.4 ┆ 8.0 ┆ 351.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 4.0 ┆ 4.0 │ #> │ max ┆ 33.9 ┆ 8.0 ┆ 472.0 ┆ … ┆ 1.0 ┆ 1.0 ┆ 5.0 ┆ 8.0 │ #> └────────────┴───────────┴──────────┴────────────┴───┴──────────┴──────────┴──────────┴────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/tidypolars-options.html","id":null,"dir":"Reference","previous_headings":"","what":"tidypolars global options — tidypolars-options","title":"tidypolars global options — tidypolars-options","text":"currently one global option: tidypolars_unknown_args controls happens arguments passed expression unknown, e.g argument prob sample(). default (\"warn\") warns user arguments ignored tidypolars. accepted value \"error\" throw error happens.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/tidypolars-options.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"tidypolars global options — tidypolars-options","text":"","code":"options(tidypolars_unknown_args = \"warn\") test <- polars::pl$DataFrame(x = c(2, 1, 5, 3, 1)) # The default is to warn the user mutate(test, x2 = sample(x, prob = 0.5)) #> Warning: #> Package tidypolars doesn't know how to use some arguments of `sample()`. #> The following argument(s) will be ignored: `prob`. #> shape: (5, 2) #> ┌─────┬─────┐ #> │ x ┆ x2 │ #> │ --- ┆ --- │ #> │ f64 ┆ f64 │ #> ╞═════╪═════╡ #> │ 2.0 ┆ 1.0 │ #> │ 1.0 ┆ 5.0 │ #> │ 5.0 ┆ 1.0 │ #> │ 3.0 ┆ 3.0 │ #> │ 1.0 ┆ 2.0 │ #> └─────┴─────┘ # But one can make this stricter and throw an error when this happens options(tidypolars_unknown_args = \"error\") try(mutate(test, x2 = sample(x, prob = 0.5))) #> Error in mutate(test, x2 = sample(x, prob = 0.5)) : #> Error while running function `sample()` in Polars. #> ✖ Package tidypolars doesn't know how to use some arguments of `sample()`: `prob`. #> ℹ Use `options(tidypolars_unknown_args = \"warn\")` to warn when this happens instead of throwing an error. options(tidypolars_unknown_args = \"warn\")"},{"path":"https://tidypolars.etiennebacher.com/reference/tidypolars-package.html","id":null,"dir":"Reference","previous_headings":"","what":"tidypolars: Get the Power of Polars with the Syntax of the Tidyverse — tidypolars-package","title":"tidypolars: Get the Power of Polars with the Syntax of the Tidyverse — tidypolars-package","text":"Polars amazing cross-language tool manipulating large data. However, one drawback R implementation syntax look odd many R users used Python syntax. objective tidypolars improve ease--use Polars R providing tidyverse syntax polars.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/reference/tidypolars-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"tidypolars: Get the Power of Polars with the Syntax of the Tidyverse — tidypolars-package","text":"Maintainer: Etienne Bacher etienne.bacher@protonmail.com [copyright holder]","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/uncount.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Uncount a Data/LazyFrame — uncount.RPolarsDataFrame","title":"Uncount a Data/LazyFrame — uncount.RPolarsDataFrame","text":"duplicates rows according weighting variable (expression). opposite count().","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/uncount.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Uncount a Data/LazyFrame — uncount.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' uncount(data, weights, ..., .remove = TRUE, .id = NULL) # S3 method for class 'RPolarsLazyFrame' uncount(data, weights, ..., .remove = TRUE, .id = NULL)"},{"path":"https://tidypolars.etiennebacher.com/reference/uncount.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Uncount a Data/LazyFrame — uncount.RPolarsDataFrame","text":"data Polars Data/LazyFrame weights vector weights. Evaluated context data. ... Dots empty. .remove TRUE, weights name column data, column removed. .id Supply string create new variable gives unique identifier created row.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/uncount.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Uncount a Data/LazyFrame — uncount.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame(x = c(\"a\", \"b\"), y = 100:101, n = c(1, 2)) test #> shape: (2, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ n │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ a ┆ 100 ┆ 1.0 │ #> │ b ┆ 101 ┆ 2.0 │ #> └─────┴─────┴─────┘ uncount(test, n) #> shape: (3, 2) #> ┌─────┬─────┐ #> │ x ┆ y │ #> │ --- ┆ --- │ #> │ str ┆ i32 │ #> ╞═════╪═════╡ #> │ a ┆ 100 │ #> │ b ┆ 101 │ #> │ b ┆ 101 │ #> └─────┴─────┘ uncount(test, n, .id = \"id\") #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ id │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ u32 │ #> ╞═════╪═════╪═════╡ #> │ a ┆ 100 ┆ 1 │ #> │ b ┆ 101 ┆ 1 │ #> │ b ┆ 101 ┆ 2 │ #> └─────┴─────┴─────┘ # using constants uncount(test, 2) #> shape: (4, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ n │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ a ┆ 100 ┆ 1.0 │ #> │ a ┆ 100 ┆ 1.0 │ #> │ b ┆ 101 ┆ 2.0 │ #> │ b ┆ 101 ┆ 2.0 │ #> └─────┴─────┴─────┘ # using expressions uncount(test, 2 / n) #> shape: (3, 3) #> ┌─────┬─────┬─────┐ #> │ x ┆ y ┆ n │ #> │ --- ┆ --- ┆ --- │ #> │ str ┆ i32 ┆ f64 │ #> ╞═════╪═════╪═════╡ #> │ a ┆ 100 ┆ 1.0 │ #> │ a ┆ 100 ┆ 1.0 │ #> │ b ┆ 101 ┆ 2.0 │ #> └─────┴─────┴─────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/unite.RPolarsDataFrame.html","id":null,"dir":"Reference","previous_headings":"","what":"Unite multiple columns into one by pasting strings together — unite.RPolarsDataFrame","title":"Unite multiple columns into one by pasting strings together — unite.RPolarsDataFrame","text":"Unite multiple columns one pasting strings together","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/unite.RPolarsDataFrame.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Unite multiple columns into one by pasting strings together — unite.RPolarsDataFrame","text":"","code":"# S3 method for class 'RPolarsDataFrame' unite(data, col, ..., sep = \"_\", remove = TRUE, na.rm = FALSE) # S3 method for class 'RPolarsLazyFrame' unite(data, col, ..., sep = \"_\", remove = TRUE, na.rm = FALSE)"},{"path":"https://tidypolars.etiennebacher.com/reference/unite.RPolarsDataFrame.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Unite multiple columns into one by pasting strings together — unite.RPolarsDataFrame","text":"data Polars Data/LazyFrame col name new column, string symbol. ... expression accepted dplyr::select(): variable names, column numbers, select helpers, etc. sep Separator use values. remove TRUE, remove input columns output Data/LazyFrame. na.rm TRUE, missing values replaced empty string prior uniting value.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/unite.RPolarsDataFrame.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Unite multiple columns into one by pasting strings together — unite.RPolarsDataFrame","text":"","code":"test <- polars::pl$DataFrame( year = 2009:2011, month = 10:12, day = c(11L, 22L, 28L), name_day = c(\"Monday\", \"Thursday\", \"Wednesday\") ) # By default, united columns are dropped unite(test, col = \"full_date\", year, month, day, sep = \"-\") #> shape: (3, 2) #> ┌───────────┬────────────┐ #> │ name_day ┆ full_date │ #> │ --- ┆ --- │ #> │ str ┆ str │ #> ╞═══════════╪════════════╡ #> │ Monday ┆ 2009-10-11 │ #> │ Thursday ┆ 2010-11-22 │ #> │ Wednesday ┆ 2011-12-28 │ #> └───────────┴────────────┘ unite(test, col = \"full_date\", year, month, day, sep = \"-\", remove = FALSE) #> shape: (3, 5) #> ┌──────┬───────┬─────┬───────────┬────────────┐ #> │ year ┆ month ┆ day ┆ name_day ┆ full_date │ #> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ #> │ i32 ┆ i32 ┆ i32 ┆ str ┆ str │ #> ╞══════╪═══════╪═════╪═══════════╪════════════╡ #> │ 2009 ┆ 10 ┆ 11 ┆ Monday ┆ 2009-10-11 │ #> │ 2010 ┆ 11 ┆ 22 ┆ Thursday ┆ 2010-11-22 │ #> │ 2011 ┆ 12 ┆ 28 ┆ Wednesday ┆ 2011-12-28 │ #> └──────┴───────┴─────┴───────────┴────────────┘ test2 <- polars::pl$DataFrame( name = c(\"John\", \"Jack\", \"Thomas\"), middlename = c(\"T.\", NA, \"F.\"), surname = c(\"Smith\", \"Thompson\", \"Jones\") ) # By default, NA values are kept in the character output unite(test2, col = \"full_name\", everything(), sep = \" \") #> shape: (3, 1) #> ┌──────────────────┐ #> │ full_name │ #> │ --- │ #> │ str │ #> ╞══════════════════╡ #> │ John T. Smith │ #> │ Jack NA Thompson │ #> │ Thomas F. Jones │ #> └──────────────────┘ unite(test2, col = \"full_name\", everything(), sep = \" \", na.rm = TRUE) #> shape: (3, 1) #> ┌─────────────────┐ #> │ full_name │ #> │ --- │ #> │ str │ #> ╞═════════════════╡ #> │ John T. Smith │ #> │ Jack Thompson │ #> │ Thomas F. Jones │ #> └─────────────────┘"},{"path":"https://tidypolars.etiennebacher.com/reference/write_csv_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Export data to CSV file(s) — write_csv_polars","title":"Export data to CSV file(s) — write_csv_polars","text":"Export data CSV file(s)","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_csv_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export data to CSV file(s) — write_csv_polars","text":"","code":"write_csv_polars( .data, file, ..., include_bom = FALSE, include_header = TRUE, separator = \",\", line_terminator = \"\\n\", quote = \"\\\"\", batch_size = 1024, datetime_format = NULL, date_format = NULL, time_format = NULL, float_precision = NULL, null_values = \"\", quote_style = \"necessary\" )"},{"path":"https://tidypolars.etiennebacher.com/reference/write_csv_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export data to CSV file(s) — write_csv_polars","text":".data Polars DataFrame. file File path result written. ... Ignored. include_bom Whether include UTF-8 BOM (byte order mark) CSV output. include_header Whether include header CSV output. separator Separate CSV fields symbol. line_terminator String used end row. quote Byte use quoting character. batch_size Number rows processed per thread. datetime_format format string, specifiers defined chrono Rust crate. format specified, default fractional-second precision inferred maximum timeunit found frame’s Datetime cols (). date_format format string, specifiers defined chrono Rust crate. time_format format string, specifiers defined chrono Rust crate. float_precision Number decimal places write, applied Float32 Float64 datatypes. null_values string representing null values (defaulting empty string). quote_style Determines quoting strategy used. \"necessary\" (default): puts quotes around fields necessary. necessary fields contain quote, delimiter record terminator. Quotes also necessary writing empty record (indistinguishable record one empty field). default. \"always\": puts quotes around every field. \"non_numeric\": puts quotes around fields non-numeric. Namely, writing field parse valid float integer, quotes used even aren`t strictly necessary. \"never\": never puts quotes around fields, even results invalid CSV data (e.g. quoting strings containing separator).","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_csv_polars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Export data to CSV file(s) — write_csv_polars","text":"input DataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_csv_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export data to CSV file(s) — write_csv_polars","text":"","code":"dest <- tempfile(fileext = \".csv\") mtcars |> as_polars_df() |> write_csv_polars(dest) read.csv(dest) #> mpg cyl disp hp drat wt qsec vs am gear carb #> 1 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4 #> 2 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4 #> 3 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 #> 4 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 #> 5 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2 #> 6 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1 #> 7 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4 #> 8 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2 #> 9 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2 #> 10 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4 #> 11 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4 #> 12 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3 #> 13 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3 #> 14 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3 #> 15 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4 #> 16 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4 #> 17 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4 #> 18 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1 #> 19 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2 #> 20 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1 #> 21 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1 #> 22 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2 #> 23 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2 #> 24 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4 #> 25 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2 #> 26 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1 #> 27 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2 #> 28 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2 #> 29 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4 #> 30 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6 #> 31 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8 #> 32 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2"},{"path":"https://tidypolars.etiennebacher.com/reference/write_ipc_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Export data to IPC file(s) — write_ipc_polars","title":"Export data to IPC file(s) — write_ipc_polars","text":"Export data IPC file(s)","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_ipc_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export data to IPC file(s) — write_ipc_polars","text":"","code":"write_ipc_polars( .data, file, compression = \"uncompressed\", ..., future = FALSE )"},{"path":"https://tidypolars.etiennebacher.com/reference/write_ipc_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export data to IPC file(s) — write_ipc_polars","text":".data Polars DataFrame. file File path result written. compression NULL character compression method, \"uncompressed\" \"lz4\" \"zstd\". NULL equivalent \"uncompressed\". Choose \"zstd\" good compression performance. Choose \"lz4\" fast compression/decompression. ... Ignored. future Setting TRUE write Polars' internal data structures might available Arrow implementations.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_ipc_polars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Export data to IPC file(s) — write_ipc_polars","text":"input DataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_json_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Export data to JSON file(s) — write_json_polars","title":"Export data to JSON file(s) — write_json_polars","text":"Export data JSON file(s)","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_json_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export data to JSON file(s) — write_json_polars","text":"","code":"write_json_polars(.data, file, ..., pretty = FALSE, row_oriented = FALSE)"},{"path":"https://tidypolars.etiennebacher.com/reference/write_json_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export data to JSON file(s) — write_json_polars","text":".data Polars DataFrame. file File path result written. ... Ignored. pretty Pretty serialize JSON. row_oriented Write row-oriented JSON. slower, common.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_json_polars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Export data to JSON file(s) — write_json_polars","text":"input DataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_json_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export data to JSON file(s) — write_json_polars","text":"","code":"dest <- tempfile(fileext = \".json\") mtcars |> as_polars_df() |> write_json_polars(dest) jsonlite::fromJSON(dest) #> $columns #> name datatype bit_settings #> 1 mpg Float64 #> 2 cyl Float64 #> 3 disp Float64 #> 4 hp Float64 #> 5 drat Float64 #> 6 wt Float64 #> 7 qsec Float64 #> 8 vs Float64 #> 9 am Float64 #> 10 gear Float64 #> 11 carb Float64 #> values #> 1 21.0, 21.0, 22.8, 21.4, 18.7, 18.1, 14.3, 24.4, 22.8, 19.2, 17.8, 16.4, 17.3, 15.2, 10.4, 10.4, 14.7, 32.4, 30.4, 33.9, 21.5, 15.5, 15.2, 13.3, 19.2, 27.3, 26.0, 30.4, 15.8, 19.7, 15.0, 21.4 #> 2 6, 6, 4, 6, 8, 6, 8, 4, 4, 6, 6, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 8, 8, 8, 8, 4, 4, 4, 8, 6, 8, 4 #> 3 160.0, 160.0, 108.0, 258.0, 360.0, 225.0, 360.0, 146.7, 140.8, 167.6, 167.6, 275.8, 275.8, 275.8, 472.0, 460.0, 440.0, 78.7, 75.7, 71.1, 120.1, 318.0, 304.0, 350.0, 400.0, 79.0, 120.3, 95.1, 351.0, 145.0, 301.0, 121.0 #> 4 110, 110, 93, 110, 175, 105, 245, 62, 95, 123, 123, 180, 180, 180, 205, 215, 230, 66, 52, 65, 97, 150, 150, 245, 175, 66, 91, 113, 264, 175, 335, 109 #> 5 3.90, 3.90, 3.85, 3.08, 3.15, 2.76, 3.21, 3.69, 3.92, 3.92, 3.92, 3.07, 3.07, 3.07, 2.93, 3.00, 3.23, 4.08, 4.93, 4.22, 3.70, 2.76, 3.15, 3.73, 3.08, 4.08, 4.43, 3.77, 4.22, 3.62, 3.54, 4.11 #> 6 2.620, 2.875, 2.320, 3.215, 3.440, 3.460, 3.570, 3.190, 3.150, 3.440, 3.440, 4.070, 3.730, 3.780, 5.250, 5.424, 5.345, 2.200, 1.615, 1.835, 2.465, 3.520, 3.435, 3.840, 3.845, 1.935, 2.140, 1.513, 3.170, 2.770, 3.570, 2.780 #> 7 16.46, 17.02, 18.61, 19.44, 17.02, 20.22, 15.84, 20.00, 22.90, 18.30, 18.90, 17.40, 17.60, 18.00, 17.98, 17.82, 17.42, 19.47, 18.52, 19.90, 20.01, 16.87, 17.30, 15.41, 17.05, 18.90, 16.70, 16.90, 14.50, 15.50, 14.60, 18.60 #> 8 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1 #> 9 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 #> 10 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 5, 4 #> 11 4, 4, 1, 1, 2, 1, 4, 2, 2, 4, 4, 3, 3, 3, 4, 4, 4, 1, 2, 1, 1, 2, 2, 4, 2, 1, 2, 2, 4, 6, 8, 2 #>"},{"path":"https://tidypolars.etiennebacher.com/reference/write_ndjson_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Export data to NDJSON file(s) — write_ndjson_polars","title":"Export data to NDJSON file(s) — write_ndjson_polars","text":"Export data NDJSON file(s)","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_ndjson_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export data to NDJSON file(s) — write_ndjson_polars","text":"","code":"write_ndjson_polars(.data, file)"},{"path":"https://tidypolars.etiennebacher.com/reference/write_ndjson_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export data to NDJSON file(s) — write_ndjson_polars","text":".data Polars DataFrame. file File path result written.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_ndjson_polars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Export data to NDJSON file(s) — write_ndjson_polars","text":"input DataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_ndjson_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export data to NDJSON file(s) — write_ndjson_polars","text":"","code":"dest <- tempfile(fileext = \".ndjson\") mtcars |> as_polars_df() |> write_ndjson_polars(dest) jsonlite::stream_in(file(dest), verbose = FALSE) #> mpg cyl disp hp drat wt qsec vs am gear carb #> 1 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4 #> 2 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4 #> 3 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 #> 4 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 #> 5 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2 #> 6 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1 #> 7 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4 #> 8 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2 #> 9 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2 #> 10 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4 #> 11 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4 #> 12 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3 #> 13 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3 #> 14 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3 #> 15 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4 #> 16 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4 #> 17 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4 #> 18 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1 #> 19 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2 #> 20 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1 #> 21 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1 #> 22 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2 #> 23 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2 #> 24 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4 #> 25 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2 #> 26 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1 #> 27 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2 #> 28 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2 #> 29 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4 #> 30 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6 #> 31 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8 #> 32 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2"},{"path":"https://tidypolars.etiennebacher.com/reference/write_parquet_polars.html","id":null,"dir":"Reference","previous_headings":"","what":"Export data to Parquet file(s) — write_parquet_polars","title":"Export data to Parquet file(s) — write_parquet_polars","text":"Export data Parquet file(s)","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_parquet_polars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export data to Parquet file(s) — write_parquet_polars","text":"","code":"write_parquet_polars( .data, file, ..., compression = \"zstd\", compression_level = 3, statistics = TRUE, row_group_size = NULL, data_page_size = NULL, partition_by = NULL, partition_chunk_size_bytes = 4294967296 )"},{"path":"https://tidypolars.etiennebacher.com/reference/write_parquet_polars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export data to Parquet file(s) — write_parquet_polars","text":".data Polars DataFrame. file File path result written. ... Ignored. compression compression method. One : \"uncompressed\" \"zstd\" (default): good compression performance \"lz4\": fast compression / decompression \"snappy\": backwards compatibility guarantees deal older parquet readers. \"gzip\", \"lzo\", \"brotli\" compression_level level compression use (default 3). used compression one \"gzip\", \"brotli\", \"zstd\". Higher compression means smaller files disk. \"gzip\" : min-level = 0, max-level = 10 \"brotli\" : min-level = 0, max-level = 11 \"zstd\" : min-level = 1, max-level = 22. statistics Whether compute write column statistics (default FALSE). requires computations. row_group_size Size row groups number rows. NULL (default), chunks DataFrame used. Writing smaller chunks may reduce memory pressure improve writing speeds. data_page_size NULL (default), limit around 1MB. partition_by Column(s) partition . partitioned dataset written specified. partition_chunk_size_bytes Approximate size split DataFrames within single partition writing. Note calculated using size DataFrame memory - size output file may differ depending file format / compression.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_parquet_polars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Export data to Parquet file(s) — write_parquet_polars","text":"input DataFrame.","code":""},{"path":"https://tidypolars.etiennebacher.com/reference/write_parquet_polars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export data to Parquet file(s) — write_parquet_polars","text":"","code":"dest <- tempfile(fileext = \".parquet\") mtcars |> as_polars_df() |> write_parquet_polars(dest) nanoparquet::read_parquet(dest) #> # A data frame: 32 × 11 #> mpg cyl disp hp drat wt qsec vs am gear carb #> #> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 #> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4 #> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1 #> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1 #> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2 #> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1 #> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4 #> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2 #> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2 #> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 #> # ℹ 22 more rows"},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-development-version","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars (development version)","text":"Added support stringr::str_replace_na() (#153). Better checks unknown unsupported arguments compute(), collect(), *_join(), pivot_*(), sink_*(), slice_sample() uncount()(#158, thanks @fkohrt report). Now, functions receive: argument exists tidyverse implementation supported tidypolars, warn user. default behaviour can changed error instead options(tidypolars_unknown_args = \"error\"). argument doesn’t exist , error.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-development-version","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars (development version)","text":"slice_sample() now errors unknown unsupported arguments passed (thanks @fkohrt report).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-0120","dir":"Changelog","previous_headings":"","what":"tidypolars 0.12.0","title":"tidypolars 0.12.0","text":"tidypolars requires polars >= 0.21.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-12-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.12.0","text":"summarize() now drops last group output default (consistency dplyr). Previously kept groups input data (#149).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-12-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.12.0","text":"Add support argument .groups summarize(). Value \"rowwise\" supported now (#149). Added support dplyr::lead(). dplyr::lead() dplyr::lag(), arguments default order_by now supported (#151).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-0110","dir":"Changelog","previous_headings":"","what":"tidypolars 0.11.0","title":"tidypolars 0.11.0","text":"tidypolars requires polars >= 0.20.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-11-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.11.0","text":"arrange() now errors unknown variable names (like dplyr::arrange()). Previously, unknown variables silently ignored. Using expressions (like + b) now accepted (#144). parameter inherit_optimization removed sink_*() functions.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-11-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.11.0","text":"power operators ^ ** now work. New function sink_ndjson() write results lazy query NDJSON file without collecting memory. inner_join() now accepts inequality joins argument, including following helpers: (), overlaps(), within() (#148).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-11-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.11.0","text":"Using external object case_when(), ifelse() ifelse() now works. str_sub() doesn’t error anymore start positive end negative. read_*_polars() functions used return standard data.frame mistake. now return Polars DataFrame. Using [ subsetting expressions now works. Thanks @ginolhac report (#141). bind_cols_polars() bind_rows_polars() now error (expected ) elements mix Polars DataFrames LazyFrames.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-10-1","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.10.1","text":"error handling columns datatype Null. Note converting columns R .data.frame(), as_tibble(), collect() still issue polars 0.19.1.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-0100","dir":"Changelog","previous_headings":"","what":"tidypolars 0.10.0","title":"tidypolars 0.10.0","text":"tidypolars requires polars >= 0.19.1.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-and-deprecations-0-10-0","dir":"Changelog","previous_headings":"","what":"Breaking changes and deprecations","title":"tidypolars 0.10.0","text":"describe() deprecated tidypolars 0.10.0 removed future update. Use summary() arguments instead (#127). describe_plan() describe_optimized_plan() deprecated tidypolars 0.10.0 removed future update. Use explain() optimized = TRUE/FALSE instead (#128). sink_parquet() sink_csv(), arguments except .data path must named (#136).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-10-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.10.0","text":"Add support functions: package base: substr(). Better error message function can come several packages one version translated (#130). row_number() now works without argument (#131). New functions import data Polars DataFrames LazyFrames (#136): read__polars() import data Polars DataFrame; scan__polars() import data Polars LazyFrame; can “csv”, “ipc”, “json”, “parquet”. can replace functions polars. example, polars::pl$read_parquet(...) can replaced read_parquet_polars(...). New functions write Polars DataFrames external files: write__polars() can “csv”, “ipc”, “json”, “ndjson”, “parquet” (#136). New function sink_ipc() similar sink_parquet() sink_csv() IPC files (#136). across() now throws better error message user passes external list .fns. works dplyr work tidypolars (#135). Added support argument .add group_by().","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-10-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.10.0","text":"stringr::str_sub() now works start end negative. Fixed bug str_sub() start greater 1. stringr::str_starts() stringr::str_ends() now work regex. fill() doesn’t error anymore ... empty. Instead, returns input data. unite() now provides proper error message col missing. unite() doesn’t error anymore ... empty. Instead, uses variables dataset. filter(), mutate() summarize() now work using column another data.frame, e.g.  replace_na() longer converts column datatype replacement, e.g. data |> replace_na(\"\") error input data numeric. n_distinct() now correctly applies na.rm argument several columns passed input (#137).","code":"my_polars_df |> filter(x %in% some_data_frame$y)"},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-090","dir":"Changelog","previous_headings":"","what":"tidypolars 0.9.0","title":"tidypolars 0.9.0","text":"tidypolars requires polars >= 0.18.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-9-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.9.0","text":"Add support several functions: package base: %% %/%. package dplyr: dense_rank(), row_number(). package lubridate: wday(). Better handling missing values match R behavior. following functions, least one missing value na.rm = FALSE (default), output NA: max(), mean(), median(), min(), sd(), sum(), var() (#120). New argument cluster_with_columns collect(), compute(), fetch(). Add global option tidypolars_unknown_args control happens tidypolars doesn’t know handle argument function. default warn accepted value \"error\".","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-9-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.9.0","text":"count() add_count() longer overwrite variable named n argument name unspecified.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-080","dir":"Changelog","previous_headings":"","what":"tidypolars 0.8.0","title":"tidypolars 0.8.0","text":"tidypolars requires polars >= 0.17.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-8-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.8.0","text":"announced tidypolars 0.7.0, behavior collect() changed. now returns standard R data.frame Polars DataFrame anymore. Replace collect() compute() (arguments) keep old behavior. bind_rows_polars(), .id passed, resulting column now type character instead integer.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-8-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.8.0","text":"Add support several functions: package base: (), (), diff(), ISOdatetime(), length(), rev(), unique(). package dplyr: consecutive_id(), min_rank(), na_if(), n_distinct(), nth(). package lubridate: make_datetime(). package stringr: str_dup(), str_split(), str_split_i(), str_trunc(). package tidyr: replace_na() (data.frame method already translated vector one can used mutate() example). now possible use explicit namespaces (dplyr::first() instead first()) mutate(), summarize() filter() (#114). bind_rows_polars(), elements named .id specified, .id column use names elements (#116). now possible rename variables select() (#117). Add support argument na_matches join functions (except cross_join() doesn’t need ) (#109).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-8-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.8.0","text":"Local variables custom functions used tidypolars functions (reported blog post Art Steinmetz). now fixed. across() now works .cols contains one variable .fns contains one function. across(), .cols argument now takes account variables created mutate() summarize() call across(). Note () function supported . example: return 0 variable foo. warning emitted behavior. Better handling negative values c() called mutate() summarize().","code":"as_polars_df(mtcars) |> head(n = 3) |> mutate( foo = 1, across(.cols = contains(\"oo\"), \\(x) x - 1) ) shape: (3, 12) ┌──────┬─────┬───────┬───────┬───┬─────┬──────┬──────┬─────┐ │ mpg ┆ cyl ┆ disp ┆ hp ┆ … ┆ am ┆ gear ┆ carb ┆ foo │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ ╞══════╪═════╪═══════╪═══════╪═══╪═════╪══════╪══════╪═════╡ │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 0.0 │ │ 21.0 ┆ 6.0 ┆ 160.0 ┆ 110.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 4.0 ┆ 0.0 │ │ 22.8 ┆ 4.0 ┆ 108.0 ┆ 93.0 ┆ … ┆ 1.0 ┆ 4.0 ┆ 1.0 ┆ 0.0 │ └──────┴─────┴───────┴───────┴───┴─────┴──────┴──────┴─────┘ as_polars_df(mtcars) |> mutate( foo = 1, across(.cols = where(is.numeric), \\(x) x - 1) )"},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-070","dir":"Changelog","previous_headings":"","what":"tidypolars 0.7.0","title":"tidypolars 0.7.0","text":"tidypolars requires polars >= 0.16.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-and-deprecations-0-7-0","dir":"Changelog","previous_headings":"","what":"Breaking changes and deprecations","title":"tidypolars 0.7.0","text":"as_polars() now removed. deprecated 0.6.0. Use as_polars_df() as_polars_lf() instead. to_r() now removed. deprecated 0.6.0. Use .data.frame() as_tibble() instead. consistency dplyr, behavior collect() change 0.8.0 perform lazy query convert result standard data.frame. now, collect() throws warning future change. recommended use compute() perform query get Polars DataFrame output (#101).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-7-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.7.0","text":"Several improvements changes pivot_wider() (#95): names_from can now takes several variables; add support id_cols names_glue; default value names_sep now _, consistency tidyr; fix documentation pivot_wider() doesn’t work LazyFrame. Add support stringr::regex(). Note argument ignore_case supported now (#97). Add support several lubridate functions: dweeks(), ddays(), dhours(), dminutes(), dseconds(), dmilliseconds(), make_date() (#107). polars function called internally fails, original error message now displayed. Add support group_split() (DataFrame ). Add support argument relationship left_join(), right_join(), full_join() inner_join() (#106).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-060","dir":"Changelog","previous_headings":"","what":"tidypolars 0.6.0","title":"tidypolars 0.6.0","text":"tidypolars requires polars >= 0.15.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-and-deprecations-0-6-0","dir":"Changelog","previous_headings":"","what":"Breaking changes and deprecations","title":"tidypolars 0.6.0","text":"as_polars() deprecated removed 0.7.0. Use as_polars_lf() as_polars_df() instead. as_polars() doesn’t argument with_string_cache anymore. set TRUE, enabled string cache globally, lead undesirable side effects. to_r() deprecated removed 0.7.0. Use .data.frame() as_tibble() instead. used silently return LazyFrame input LazyFrame. now automatically collects LazyFrame (#88). pull() nows automatically collects input LazyFrame (#89).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-6-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.6.0","text":"Add support argument .keep mutate() (#80). Add support group_vars() group_keys() (#81). Experimental support rowwise(). now, limited functions: mean(), median(), min(), max(), sum(), (), (). rowwise() group_by() used time (#40). functions return polars Data/LazyFrame now add class \"tidypolars\" output (#86). Support .min(), .max(), dplyr::n(). Support .data[[ .env[[ addition .data$ .env$. Better error messages objects specified .data .env don’t exist.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-6-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.6.0","text":"pull() now errors var length > 1.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-050","dir":"Changelog","previous_headings":"","what":"tidypolars 0.5.0","title":"tidypolars 0.5.0","text":"tidypolars requires polars >= 0.12.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-5-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.5.0","text":"across() now errors argument .cols provided (either named unnamed). behavior deprecated dplyr 1.1.0. longer possible use ! arrange() sort decreasing order, compatibility dplyr::arrange(). Use - desc() instead.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-5-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.5.0","text":"summarize() now works ungrouped data returns 1-row output. now possible use desc(x1) arrange() sort decreasing order x1 (equivalent -x1). Add support argument names_prefix pivot_longer(). Add support arguments names_prefix names_sep pivot_wider(). Add support tidyr::uncount(). *_join() functions now work specification created dplyr::join_by(). Notice limited equality joins now. can now use “embrace” operator {{ }} pass unquoted column names (among things) arguments custom functions. See “Programming dplyr” vignette examples. bind_cols_polars() now works two LazyFrames, . Add support argument .name_repair bind_cols_polars() (#74). Support .env$ .data$ pronouns expressions filter(), mutate() summarize(). Support named vector argument pattern str_replace_all(), names patterns values replacements. Using %% factor variables doesn’t require enabling string cache anymore.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-5-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.5.0","text":"summarize() longer errors across(everything(), ...) used .. *_join() functions longer error named vector provided argument . Expressions values named “literal” anymore.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"misc-0-5-0","dir":"Changelog","previous_headings":"","what":"Misc","title":"tidypolars 0.5.0","text":"Simplify procedure support new functions.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-040","dir":"Changelog","previous_headings":"","what":"tidypolars 0.4.0","title":"tidypolars 0.4.0","text":"tidypolars requires polars >= 0.11.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-4-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.4.0","text":"longer possible pass list rename().","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-4-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.4.0","text":"argument with_string_cache as_polars() now enables string cache globally set TRUE (#54). Better error message filter() comparing factors strings string cache disabled. Basic support strptime(). possible use strptime(*, strict = FALSE) error parsing characters fails. New argument .filter(), mutate(), summarize(), new argument slice_*() functions. allows operations groups without using group_by() ungroup(). See dplyr vignette information (#59). rename() now accepts unquoted names old new names. Support fixed regexes str_detect() (using fixed()) grepl() (using fixed = TRUE).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-4-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.4.0","text":"Improve robustness sequential expressions mutate() summarize() (.e expressions run one depend variables created call) (#58). relocate() now works correctly .= last_col(). functions work grouped data now correctly restore groups structure (#62).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"misc-0-4-0","dir":"Changelog","previous_headings":"","what":"Misc","title":"tidypolars 0.4.0","text":"Error messages coming mutate(), summarize(), filter() now give right function call. Faster tidy selection (#61).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-030","dir":"Changelog","previous_headings":"","what":"tidypolars 0.3.0","title":"tidypolars 0.3.0","text":"tidypolars requires polars >= 0.10.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"breaking-changes-0-3-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"tidypolars 0.3.0","text":"functions starting pl_ removed benefit S3 methods. example, pl_distinct() doesn’t exist anymore way use load dplyr use distinct() Polars DataFrame LazyFrame. avoid confusion compatibility dplyr tidyr. See #49 detailed explanation. pl_bind_rows() pl_bind_cols() renamed bind_rows_polars() bind_cols_polars() respectively. bind_rows() bind_cols() S3 methods (might change future versions dplyr).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-3-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.3.0","text":"New function duplicated_rows() opposite distinct() (#50). New argument .id bind_rows_polars(). bind_rows_polars() can now bind Data/LazyFrames don’t schema. Columns upcast common types necessary. Unknown columns filled NA.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-3-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.3.0","text":"complete() now works correctly grouped data.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"misc-0-3-0","dir":"Changelog","previous_headings":"","what":"Misc","title":"tidypolars 0.3.0","text":"relig_income fish_encounters reexported anymore since tidyr now imported.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-020","dir":"Changelog","previous_headings":"","what":"tidypolars 0.2.0","title":"tidypolars 0.2.0","text":"tidypolars requires polars >= 0.9.0.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-2-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.2.0","text":"Rename pl_fetch() fetch(). New functions supported: describe(), sink_csv(), slice_sample(). New argument fill pl_complete(). Support stringr::str_to_title() tools::toTitleCase(). Support stringr::fixed() use literal strings. Support replacements captured groups like \\\\1 stringr::str_replace() stringr::str_replace_all().","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-2-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.2.0","text":"sink_parquet() didn’t use user inputs (apart path).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"misc-0-2-0","dir":"Changelog","previous_headings":"","what":"Misc","title":"tidypolars 0.2.0","text":"Clearer error message expression contains ::. supported now potentially implemented later. pl_colnames() longer exported.","code":""},{"path":[]},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"new-features-0-1-0","dir":"Changelog","previous_headings":"","what":"New features","title":"tidypolars 0.1.0","text":"Support .numeric(), .character(), .logical(), grepl(), paste() expressions pl_filter(), pl_mutate() pl_summarize(). Support sink_parquet() (#38). Support fetch() (#42). Support additional stringr functions: str_detect(), str_extract_all(), str_pad(), str_squish(), str_trim(), word() (arguments corner cases supported yet). Add optimization parameters collect().","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"bug-fixes-0-1-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"tidypolars 0.1.0","text":"Fix pl_mutate() pl_summarize() expressions use variables previously created modified (#10, #37). Fix bug pl_filter() passing vector RHS %%.","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"misc-0-1-0","dir":"Changelog","previous_headings":"","what":"Misc","title":"tidypolars 0.1.0","text":"Improve backend translate R expressions Polars expressions. also led complete rewriting vignette “R Polars expressions” (#27). Error messages now report correct function call. Improve CI coverage (#35).","code":""},{"path":"https://tidypolars.etiennebacher.com/news/index.html","id":"tidypolars-001","dir":"Changelog","previous_headings":"","what":"tidypolars 0.0.1","title":"tidypolars 0.0.1","text":"First Github release.","code":""}]