jpskill.com
📦 その他 コミュニティ

coding-r

R: data frames, tidyverse, ggplot2, statistical modeling, RMarkdown, Shiny, package development

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o coding-r.zip https://jpskill.com/download/22089.zip && unzip -o coding-r.zip && rm coding-r.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/22089.zip -OutFile "$d\coding-r.zip"; Expand-Archive "$d\coding-r.zip" -DestinationPath $d -Force; ri "$d\coding-r.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して coding-r.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → coding-r フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

目的

このスキルは、AIがtidyverseやggplot2などのパッケージを使用して、データフレーム、統計モデリング、RMarkdownレポート、Shinyアプリ、およびパッケージ開発に焦点を当てたデータ操作、視覚化、分析のためのRプログラミングタスクを実行できるようにします。

使用場面

  • データセットのクリーンアップや変換など、データフレームで表形式データを扱う場合。
  • 散布図やヒストグラムなど、ggplot2で視覚化を作成する場合。
  • データセットに対する線形回帰など、統計モデリングのシナリオで。
  • Shinyでインタラクティブなアプリを構築したり、RMarkdownを介してレポートを生成したりする場合。
  • カスタムデータサイエンスワークフローのためにRパッケージを開発または拡張する場合。

主な機能

  • tidyverse関数(例:フィルタリングやミューテートのためのdplyr)を使用してデータフレームを操作します。
  • レイヤー、テーマ、ファセットを含むggplot2でプロットを生成します。
  • 回帰のためのlm()などのベースRまたはパッケージで統計モデリングを実行します。
  • コードチャンクと出力を含む、再現可能なレポートのためのRMarkdownドキュメントを作成します。
  • インタラクティブなダッシュボードのためのShinyアプリと、devtoolsを使用したパッケージ開発を行います。
  • CSVからの読み込みやデータベースへの接続など、データサイエンスパイプラインと統合します。

使用パターン

エージェントコマンドでは、常にRコードの前にスキルID「coding-r」を付けます。例:「Use coding-r to load and plot data」。応答ではコードブロックを介して呼び出し、スクリプトが自己完結型であることを確認してください。複数ステップのタスクの場合、関数に分割します。まずライブラリをロードし、次にデータを処理し、最後に結果を出力します。複雑なワークフローにはRスクリプト(.Rファイル)を使用し、source("script.R")で呼び出します。環境変数が必要な場合(例:パッケージ内のAPIキーの場合)、コードを実行する前にSys.setenv(API_KEY = "$MY_API_KEY")のように設定します。

一般的なコマンド/API

  • tidyverseのロード:library(tidyverse)の後にdf <- read_csv("data.csv") %>% filter(column > 10)
  • ggplotの作成:library(ggplot2); ggplot(df, aes(x=var1, y=var2)) + geom_point() + theme_minimal()
  • 統計モデリング:model <- lm(y ~ x, data=df); summary(model)
  • RMarkdownの基本:.Rmdファイルで--- title: "Report" output: html_document ---から始め、{r} print(summary(df))のようなコードチャンクを追加します。
  • Shinyアプリのスケルトン:library(shiny); ui <- fluidPage(); server <- function(input, output) {}; shinyApp(ui, server)
  • パッケージ開発:devtools::create("mypackage")を使用して初期化し、R/フォルダーに関数を追加します。

統合に関する注意点

Rコードをより大きなワークフローに統合するには、rpy2を介してPythonに埋め込む(例:import rpy2.robjects as robjects; robjects.r('library(tidyverse)'))か、Python-Rブリッジングのためにreticulateを使用します。Webサービスの場合、ShinyアプリをShiny Serverまたはshinyapps.ioにデプロイし、認証のために$SHINY_API_KEYのような環境変数で設定します。パラメーターには設定ファイル(例:YAML)を使用します。api_key: $MY_API_KEYを含むconfig.ymlを作成し、Rでyaml::yaml.load_file("config.yml")で読み込みます。Rのバージョン互換性(例:>=4.0)を確認し、実行前にinstall.packages(c("tidyverse", "ggplot2"))で依存関係をインストールしてください。

エラー処理

堅牢なコードのためにtryCatch()を使用します:tryCatch({ result <- lm(y ~ x, data=df) }, error = function(e) print(paste("Error:", e)))if (!require(tidyverse)) install.packages("tidyverse")で不足しているパッケージを確認します。操作の前にdf <- df %>% drop_na()でNA値などのデータの問題を処理します。Shinyの場合、shiny::runApp(launch.browser=TRUE)でデバッグし、options(shiny.error = recover)でエラーをログに記録します。常にif (is.null(df)) stop("Data frame is missing")のように入力を検証します。API呼び出しが失敗した場合(例:httrパッケージで)、httr::RETRY("GET", url, times=3)で再試行します。

具体的な使用例

  1. データ分析とプロット: CSVファイルを分析し、散布図を作成するには、次を使用します:library(tidyverse); library(ggplot2); df <- read_csv("data.csv"); ggplot(df, aes(x=age, y=income)) + geom_point() + labs(title="Age vs Income")。これによりデータがロードされ、必要に応じてフィルタリングされ、プロットが出力されます。

  2. RMarkdownでの統計モデリング: 回帰レポートの場合、RMarkdownファイルを作成します:--- output: html_document --- # Analysis ````{r} library(tidyverse); model <- lm(sales ~ advertising, data=df); summary(model) ````。rmarkdown::render("report.Rmd")`でレンダリングし、結果を含むHTML出力を生成します。

グラフの関係性

  • 関連:ID: coding-python(統合ワークフローのためにデータサイエンスクラスターを共有)
  • 関連:ID: coding-julia(統計モデリングとデータ分析で重複)
  • タグで接続:「statistics」(data-analysisなどの他のスキルと)、「coding」クラスター(一般的なプログラミングツール用)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Purpose

This skill allows the AI to execute R programming tasks for data manipulation, visualization, and analysis using packages like tidyverse and ggplot2, focusing on data frames, statistical modeling, RMarkdown reports, Shiny apps, and package development.

When to Use

  • When handling tabular data with data frames, such as cleaning and transforming datasets.
  • For creating visualizations with ggplot2, like scatter plots or histograms.
  • In statistical modeling scenarios, e.g., linear regression on datasets.
  • Building interactive apps with Shiny or generating reports via RMarkdown.
  • Developing or extending R packages for custom data science workflows.

Key Capabilities

  • Manipulate data frames using tidyverse functions (e.g., dplyr for filtering and mutating).
  • Generate plots with ggplot2, including layers, themes, and faceting.
  • Perform statistical modeling with base R or packages like lm() for regression.
  • Create RMarkdown documents for reproducible reports, including code chunks and outputs.
  • Develop Shiny apps for interactive dashboards and package development using devtools.
  • Integrate with data science pipelines, such as reading from CSV or connecting to databases.

Usage Patterns

Always prefix R code with the skill ID "coding-r" in agent commands, e.g., "Use coding-r to load and plot data". Invoke via code blocks in responses, ensuring scripts are self-contained. For multi-step tasks, break into functions: first load libraries, then process data, and finally output results. Use R scripts (.R files) for complex workflows, calling them with source("script.R"). If environment variables are needed (e.g., for API keys in packages), set them like Sys.setenv(API_KEY = "$MY_API_KEY") before running code.

Common Commands/API

  • Load tidyverse: library(tidyverse) followed by df <- read_csv("data.csv") %>% filter(column > 10).
  • Create a ggplot: library(ggplot2); ggplot(df, aes(x=var1, y=var2)) + geom_point() + theme_minimal().
  • Statistical modeling: model <- lm(y ~ x, data=df); summary(model).
  • RMarkdown basics: Start with --- title: "Report" output: html_document --- in a .Rmd file, then add code chunks like {r} print(summary(df)).
  • Shiny app skeleton: library(shiny); ui <- fluidPage(); server <- function(input, output) {}; shinyApp(ui, server).
  • Package development: Use devtools::create("mypackage") to initialize, then add functions in R/ folder.

Integration Notes

Integrate R code into larger workflows by embedding in Python via rpy2 (e.g., import rpy2.robjects as robjects; robjects.r('library(tidyverse)')), or use reticulate for Python-R bridging. For web services, deploy Shiny apps on Shiny Server or shinyapps.io, configuring with environment variables like $SHINY_API_KEY for authentication. Use config files (e.g., YAML) for parameters: create a config.yml with api_key: $MY_API_KEY, then read in R with yaml::yaml.load_file("config.yml"). Ensure R version compatibility (e.g., >=4.0) and install dependencies via install.packages(c("tidyverse", "ggplot2")) before execution.

Error Handling

Use tryCatch() for robust code: tryCatch({ result <- lm(y ~ x, data=df) }, error = function(e) print(paste("Error:", e))). Check for missing packages with if (!require(tidyverse)) install.packages("tidyverse"). Handle data issues like NA values with df <- df %>% drop_na() before operations. For Shiny, debug with shiny::runApp(launch.browser=TRUE) and log errors via options(shiny.error = recover). Always validate inputs, e.g., if (is.null(df)) stop("Data frame is missing"). If API calls fail (e.g., in httr package), retry with httr::RETRY("GET", url, times=3).

Concrete Usage Examples

  1. Data Analysis and Plotting: To analyze a CSV file and create a scatter plot, use: library(tidyverse); library(ggplot2); df <- read_csv("data.csv"); ggplot(df, aes(x=age, y=income)) + geom_point() + labs(title="Age vs Income"). This loads data, filters if needed, and outputs the plot.

  2. Statistical Modeling in RMarkdown: For a regression report, create an RMarkdown file: --- output: html_document --- # Analysis ````{r} library(tidyverse); model <- lm(sales ~ advertising, data=df); summary(model) ````. Render withrmarkdown::render("report.Rmd")` to generate an HTML output with results.

Graph Relationships

  • Related to: ID: coding-python (shares data science cluster for integrated workflows)
  • Related to: ID: coding-julia (overlaps in statistical modeling and data analysis)
  • Connected via tags: "statistics" with other skills like data-analysis, and "coding" cluster for general programming tools