{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"R 言語ドライバのインストール","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-言語ドライバのインストール","__idx":0},"children":["R 言語ドライバのインストール"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この記事では、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://rpubs.com/chezou/TD-from-RPresto-RTD"},"children":["RPresto"]}," パッケージを使用して、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://www.r-project.org/"},"children":["R 言語"]}," で Treasure Data を使用する方法を説明します。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#install-the-rpresto-package"},"children":["RPresto パッケージのインストール"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#your-local-endpoint"},"children":["ローカルエンドポイント"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#issuing-queries"},"children":["クエリの発行"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"rpresto-パッケージのインストール","__idx":1},"children":["RPresto パッケージのインストール"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["R コンソールを開きます。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次に、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://rpubs.com/chezou/TD-from-RPresto-RTD"},"children":["RPresto"]}," と ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/RTD/"},"children":["RTD"]}," パッケージを次のようにインストールします:"]}]}]},{"$$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":["R 言語に RODBC lib を使用する場合は、代わりに RJDBC lib を使用してください。RJDBC を使用すると、汎用の Trino/Presto JDBC ドライバを設定できます。R 言語から Treasure Data Trino にアクセスできるようになります。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"ローカルエンドポイント","__idx":2},"children":["ローカルエンドポイント"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のエンドポイントを使用してこの機能にアクセスできます。RPresto の場合は Presto JDBC を、RTD では API が使用される可能性があります。",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/apis/endpoints/endpoints"},"children":["Treasure Data サイトとエンドポイント"]},"の詳細をご覧ください。"]},{"$$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":["サイト"]}]},{"$$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 (ベータ版)"]}]},{"$$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":"クエリの発行","__idx":3},"children":["クエリの発行"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下の例でクエリを実行できます。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'test'"]}," データベースに ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'flights'"]}," テーブルがあると仮定して、Treasure API キーの環境変数 <",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TD_API_KEY"]},"> を設定する必要があります。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["別の地域を使用するには、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["host"]}," を目的の地域に置き換えます。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dplyr.tidyverse.org/"},"children":["dplyr"]}," パッケージの使用"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://solutions.posit.co/connections/db/r-packages/dbi/"},"children":["DBI"]}," パッケージの使用"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"例-1-rpresto-と-dplyr-を使用","__idx":4},"children":["例 1 (RPresto と 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":"例-2-rpresto-と-dbi-を使用","__idx":5},"children":["例 2 (RPresto と 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":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://rpubs.com/chezou/TD-from-RPresto-RTD"},"children":["サンプルノートブック"]}," をご覧ください。"]}]},"headings":[{"value":"R 言語ドライバのインストール","id":"r-言語ドライバのインストール","depth":1},{"value":"RPresto パッケージのインストール","id":"rpresto-パッケージのインストール","depth":1},{"value":"ローカルエンドポイント","id":"ローカルエンドポイント","depth":1},{"value":"クエリの発行","id":"クエリの発行","depth":1},{"value":"例 1 (RPresto と dplyr を使用):","id":"例-1-rpresto-と-dplyr-を使用","depth":2},{"value":"例 2 (RPresto と DBI を使用):","id":"例-2-rpresto-と-dbi-を使用","depth":2}],"frontmatter":{"seo":{"title":"R 言語ドライバのインストール"}},"lastModified":"2026-06-01T09:34:27.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/tools/cli-and-sdks/r-language-driver-install","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}