Git Product home page Git Product logo

prqlc-r's Introduction

prqlr

prqlr status badge CRAN status

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

This version supports PRQL 0.11.2.

Installation

Requires R 4.2.0 or later.

This package can be installed from CRAN or R-universe. If available, a binary package will be installed.

# Install from CRAN
install.packages("prqlr")
# 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.65 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.11.2 (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.11.2 (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.11.2 (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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.