{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"redocly_category":"Guides","type":"markdown"},"seo":{"title":"R Language Driver Install","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"r-language-driver-install","__idx":0},"children":["R Language Driver Install"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This article shows how to use Treasure Data with the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://www.r-project.org/"},"children":["R language"]}," by using the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://rpubs.com/chezou/TD-from-RPresto-RTD"},"children":["RPresto"]}," package."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#install-the-rpresto-package"},"children":["Install the RPresto Package"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#your-local-endpoint"},"children":["Your Local Endpoint"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#issuing-queries"},"children":["Issuing Queries"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"install-the-rpresto-package","__idx":1},"children":["Install the RPresto Package"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Open the R Console."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Next, install the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://rpubs.com/chezou/TD-from-RPresto-RTD"},"children":["RPresto"]}," and ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/RTD/"},"children":["RTD"]}," Package as shown:"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"r","header":{"controls":{"copy":{}}},"source":"install.packages(c(\"RPresto\", \"devtools\", \"dplyr\", \"dbplyr\", \"ggplot2\"))\ndevtools::install_github(\"treasure-data/RTD\")\ndevtools::install_github(\"crowding/msgpack-r\")\n","lang":"r"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In cases where RODBC lib is used for R Language, use RJDBC lib instead. RJDBC allows you to configure a generic Trino/Presto JDBC Driver. You'll be able to access Treasure Data Trino from R Language."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"your-local-endpoint","__idx":2},"children":["Your Local Endpoint"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can use the endpoints below to access this feature. You can point to Presto JDBC for RPresto and API might be used by RTD. Learn more about ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/apis/endpoints/endpoints"},"children":["Treasure Data Sites and Endpoints"]},"."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":""},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Site"]}]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":""},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["EU"]}]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":""},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Korea (in beta)"]}]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":""},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["US"]}]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":""},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Tokyo"]}]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Presto JDBC/ODBC"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://api-presto.eu01.treasuredata.com"},"children":["api-presto.eu01.treasuredata.com"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://api-presto.ap02.treasuredata.com"},"children":["api-presto.ap02.treasuredata.com"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://api-presto.treasuredata.com"},"children":["api-presto.treasuredata.com"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://api-presto.treasuredata.co.jp"},"children":["api-presto.treasuredata.co.jp"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://api.eu01.treasuredata.com"},"children":["api.eu01.treasuredata.com"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://api.ap02.treasuredata.com"},"children":["api.ap02.treasuredata.com"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://api.treasuredata.com"},"children":["api.treasuredata.com"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://api.treasuredata.co.jp"},"children":["api.treasuredata.co.jp"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"issuing-queries","__idx":3},"children":["Issuing Queries"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can query with the following examples. Assuming there is a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["‘flights’"]}," table in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["‘test’"]}," database, you then need to set an environment variable <",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TD_API_KEY"]},"> for your Treasure API key."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To use a different region, replace ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["host"]}," with the desired region."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Using ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dplyr.tidyverse.org/"},"children":["dplyr"]}," package"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Using ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://solutions.posit.co/connections/db/r-packages/dbi/"},"children":["DBI"]}," package"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"example-1-using-rpresto-and-dplyr","__idx":4},"children":["Example 1 (using RPresto and dplyr):"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"r","header":{"controls":{"copy":{}}},"source":"library(RPresto)\nlibrary(dplyr)\n\ndb <- src_presto(\n  host=\"https://api-presto.treasuredata.com\",\n  port=443,\n  user=Sys.getenv(\"TD_API_KEY\"),\n  schema='test',\n  catalog='td-presto'\n)\n\nflights_tbl <- tbl(db, 'flights')\n\n# filter by departure delay and show result\nflights_tbl %>% filter(dep_delay == 2)\n","lang":"r"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"example-2-using-rpresto-and-dbi","__idx":5},"children":["Example 2 (using RPresto and DBI):"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"r","header":{"controls":{"copy":{}}},"source":"library(DBI)\n\ncon <- dbConnect(\n  RPresto::Presto(),\n  host=\"https://api-presto.treasuredata.com\",\n  port=443,\n  user=Sys.getenv(\"TD_API_KEY\"),\n  schema='test',\n  catalog='td-presto'\n)\n\n# write your query with dbGetQuery function\nflights_preview <- dbGetQuery(con, 'SELECT year, month, day, dep_time, dep_delay, carrier, flight from flights limit 10')\n# show query result\nflights_preview\n","lang":"r"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["View ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://rpubs.com/chezou/TD-from-RPresto-RTD"},"children":["an example notebook"]},"."]}]},"headings":[{"value":"R Language Driver Install","id":"r-language-driver-install","depth":1},{"value":"Install the RPresto Package","id":"install-the-rpresto-package","depth":1},{"value":"Your Local Endpoint","id":"your-local-endpoint","depth":1},{"value":"Issuing Queries","id":"issuing-queries","depth":1},{"value":"Example 1 (using RPresto and dplyr):","id":"example-1-using-rpresto-and-dplyr","depth":2},{"value":"Example 2 (using RPresto and DBI):","id":"example-2-using-rpresto-and-dbi","depth":2}],"frontmatter":{"seo":{"title":"R Language Driver Install"}},"lastModified":"2026-06-01T09:09:59.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/tools/cli-and-sdks/r-language-driver-install","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}