https://github.com/pola-rs/r-polars
Polars R bindings
https://github.com/pola-rs/r-polars
arrow polars r rust
Last synced: 3 months ago
JSON representation
Polars R bindings
- Host: GitHub
- URL: https://github.com/pola-rs/r-polars
- Owner: pola-rs
- License: other
- Created: 2022-12-26T17:02:43.000Z (almost 3 years ago)
- Default Branch: next
- Last Pushed: 2025-07-05T15:31:53.000Z (3 months ago)
- Last Synced: 2025-07-07T05:05:31.514Z (3 months ago)
- Topics: arrow, polars, r, rust
- Language: R
- Homepage: https://pola-rs.github.io/r-polars/
- Size: 8.37 MB
- Stars: 513
- Watchers: 12
- Forks: 40
- Open Issues: 49
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.0.md
- License: LICENSE
Awesome Lists containing this project
- awesome-polars - rpolars for R - [R](https://www.r-project.org/) `rpolars` package to use polars DataFrame from R. (Libraries/Packages/Scripts / R)
README
---
output:
github_document:
html_preview: false
# used by altdoc
default-image-extension: ''
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# polars _(R Polars)_
[](https://community.r-multiverse.org/polars)
[](https://rpolars.r-universe.dev)
[](https://CRAN.R-project.org/package=polars)
[](https://pola-rs.github.io/r-polars)Polars is a blazingly fast DataFrame library, written in Rust.
The goal of Polars is to deliver fast, efficient data processing that:
- Utilizes all available cores on your machine.
- Optimizes queries to reduce unneeded work/memory allocations.
- Handles datasets much larger than your available RAM.
- Follows a consistent and predictable API.
- Adheres to a strict schema (data-types should be known before running the query).This polars R package provides the R bindings for Polars.
It can be used to process Polars DataFrames and other data structures,
convert objects between Polars and R, and can be integrated with other common R packages.To learn more, read the [online documentation](https://pola-rs.github.io/r-polars/) for this R package,
and the [user guide](https://docs.pola.rs/) for Python/Rust Polars.## Install
The recommended way to install this package is from the R-multiverse community repository:
```r
Sys.setenv(NOT_CRAN = "true")
install.packages("polars", repos = "https://community.r-multiverse.org")
```More recent (development) version may be installed from the rpolars R-universe repository:
```r
Sys.setenv(NOT_CRAN = "true")
install.packages('polars', repos = c("https://rpolars.r-universe.dev", "https://cloud.r-project.org"))
```## Usage
To avoid conflicts with other packages and base R function names, many of polars'
functions are hosted in the `pl` environment, and accessible via the `pl$` prefix.
Most of the functions for polars objects should be chained with the `$` operator.Additionally, the majority of the functions are intended to match the Python Polars API.
These mean that Polars queries written in Python and in R are very similar.
For example, writing the [example from the user guide of Python/Rust](https://docs.pola.rs/#example)
in R:```{r}
library(polars)# Prepare a CSV file
csv_file <- tempfile(fileext = ".csv")
write.csv(iris, csv_file, row.names = FALSE)# Create a query plan (LazyFrame) with filtering and group aggregation
q <- pl$scan_csv(csv_file)$filter(pl$col("Sepal.Length") > 5)$group_by(
"Species",
.maintain_order = TRUE
)$agg(pl$all()$sum())# Execute the query plan and collect the result as a Polars DataFrame
df <- q$collect()df
```There are also some functions to manipulate polars objects using base R and some popular other packages.
```{r}
# Subset a Polars DataFrame using the `[` operator
df[1:2, 1:2]# Execute a query plan and collect the result as a tibble data frame
tibble::as_tibble(q)
``````{r}
#| echo: false
unlink(csv_file)
```The [Get Started vignette](https://pola-rs.github.io/r-polars/vignettes/polars.html)
(`vignette("polars")`) provides a more detailed introduction.## Extensions
While one can use this package as-is, other packages build on it to
provide different APIs:- [polarssql](https://rpolars.github.io/r-polarssql/) provides a polars
backend for [DBI](https://dbi.r-dbi.org/) and [dbplyr](https://dbplyr.tidyverse.org/).
- [tidypolars](https://tidypolars.etiennebacher.com/) allows one to
use the [tidyverse](https://www.tidyverse.org/) syntax while using the power of polars.## Maintainers
- [SHIMA Tatsuya](https://github.com/eitsupi)
- [Etienne Bacher](https://github.com/etiennebacher)[Version 0 of R Polars](https://github.com/rpolars/r-polars0) was previously maintained by
[Søren Havelund Welling](https://github.com/sorhawell).## Acknowledgements
This package is based on the [Polars open source project](https://github.com/pola-rs/polars),
originally founded by [Ritchie Vink](https://github.com/ritchie46) and developed by many contributors.## License
MIT @ polars authors