Skip to content

PRQL/prqlc-r

Folders and files

NameName
Last commit message
Last commit date

Latest commit

440241c · Mar 28, 2025
Oct 22, 2023
Mar 27, 2025
Jan 19, 2025
Feb 12, 2024
Mar 27, 2025
Sep 21, 2024
Feb 5, 2023
Mar 28, 2025
Mar 27, 2025
Mar 27, 2025
Dec 23, 2023
Mar 27, 2025
Oct 23, 2022
Mar 27, 2025
Mar 13, 2023
Mar 28, 2025
Mar 28, 2025
Oct 23, 2022
Oct 23, 2022
Mar 27, 2025
Jan 19, 2025
Mar 28, 2025
Mar 28, 2025
Mar 28, 2025
Sep 19, 2024
Sep 16, 2024
Mar 28, 2025
Oct 10, 2023
Mar 27, 2025
Oct 10, 2023
Mar 28, 2025

Repository files navigation

prqlr

prqlr status badge CRAN status R-multiverse status

R bindings for the prqlc Rust library, powered by savvy.

This version supports PRQL 0.13.4.

Installation

Requires R 4.2.0 or later.

This latest release version of this package can be installed from CRAN or R-multiverse. If available, a binary package will be installed.

# Install from CRAN
install.packages("prqlr")
# Install from the R-multiverse Community Repository
install.packages("prqlr", repos = "https://community.r-multiverse.org")

Development version of this package can be installed from PRQL’s R-universe repository.

# Install from R-universe
install.packages("prqlr", repos = "https://prql.r-universe.dev")

For source installation, pre-built Rust libraries may be available if the environment variable NOT_CRAN is set to "true". (Or, set LIBPRQLR_BUILD to "false")

Sys.setenv(NOT_CRAN = "true")
install.packages("prqlr")

Or, the Rust toolchain (Rust 1.73.0 or later) must be configured to build the Rust library.

Please check the https://github.com/r-rust/hellorust repository for about Rust code in R packages.

Examples

library(prqlr)

"from mtcars | filter cyl > 6 | select {cyl, mpg}" |>
  prql_compile() |>
  cat()
#> SELECT
#>   cyl,
#>   mpg
#> FROM
#>   mtcars
#> WHERE
#>   cyl > 6
#> 
#> -- Generated by PRQL compiler version:0.13.4 (https://prql-lang.org)

PRQL’s pipelines can be joined by the newline character (\n), or actual newlines in addition to |.

"from mtcars \n filter cyl > 6 \n select {cyl, mpg}" |>
  prql_compile() |>
  cat()
#> SELECT
#>   cyl,
#>   mpg
#> FROM
#>   mtcars
#> WHERE
#>   cyl > 6
#> 
#> -- Generated by PRQL compiler version:0.13.4 (https://prql-lang.org)
"from mtcars
filter cyl > 6
select {cyl, mpg}" |>
  prql_compile() |>
  cat()
#> SELECT
#>   cyl,
#>   mpg
#> FROM
#>   mtcars
#> WHERE
#>   cyl > 6
#> 
#> -- Generated by PRQL compiler version:0.13.4 (https://prql-lang.org)

Thanks to the {tidyquery} package, we can even convert a PRQL query to a SQL query and then to a {dplyr} query!

"from mtcars
filter cyl > 6
select {cyl, mpg}" |>
  prql_compile() |>
  tidyquery::show_dplyr()
#> mtcars %>%
#>   filter(cyl > 6) %>%
#>   select(cyl, mpg)

{knitr} integration

Using {prqlr} with {knitr} makes it easy to create documents that lists PRQL queries and a translated SQL queries, or documents that lists PRQL queries and tables of data retrieved by PRQL queries.

Please check the vignette vignette("knitr", "prqlr") for details.