origin-r-coding-style

Write and review R code following tidyverse and targets conventions for climate and GIS research pipelines.

Updated Dec 9, 2025
One-click install
npx skills add https://github.com/Aki2022/skills --skill origin-r-coding-style-aki2022
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: origin-r-coding-style
Source: https://github.com/Aki2022/skills/tree/main/origin-r-coding-style
Command: npx skills add https://github.com/Aki2022/skills --skill origin-r-coding-style-aki2022

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? R codebases maintained by researchers often drift into inconsistent naming, mixed pipe styles, and non-reproducible patterns. This Skill enforces a single human-readable style standard—snake_case naming, func_ prefixes, magrittr pipes, and reproducible targets pipelines—across .R, .Rmd, and .qmd files in climate/GIS research projects. ## Core Features & Use Cases - Naming and layout rules: Enforces snake_case files and variables, func_-prefixed functions, UPPER_SNAKE_CASE constants, and 2-space indentation, with guidance for migrating legacy camelCase code incrementally. - Library selection standards: Prescribes tidyverse for data manipulation, targets/crew for pipelines, sf with GeoParquet for vector geodata, duckplyr/DuckDB for out-of-core joins, and googleCloudStorageR with ADC for cloud access. - Reproducibility practices: Covers renv lockfiles, here::here() path management, roxygen2 documentation, testthat TDD for pure functions, and a review checklist for code audits. - Use Case: When porting a legacy script with camelCase functions and absolute paths into a targets pipeline, apply this Skill to rename functions to func_ snake_case, switch paths to here::here(), and isolate side effects into thin wrappers. ## Quick Start Review my R script and rewrite it to follow the tidyverse and targets style conventions with snake_case naming.

Frequently Asked Questions about origin-r-coding-style

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write R functions in tidyverse style for a targets pipeline?

Name functions with a func_ prefix and snake_case, keep one responsibility per function, and document them with roxygen2. Define the DAG in _targets.R, constants in params.R, and use purrr::map_* or furrr instead of base for loops.

What R libraries should I use for large geospatial joins?

Use duckplyr with DuckDB spatial for out-of-core joins and aggregation, keeping dplyr syntax without loading everything into memory. Store vector data as GeoParquet via arrow or sfarrow, and reserve raw SQL through dbplyr::sql() for spatial joins only.

Should I use %>% or the native |> pipe in R?

This style standardizes on the magrittr %>% pipe because existing code uses it consistently, and mixing |> is disallowed. Consistency across the codebase takes priority over adopting the newer native pipe.

How do I migrate legacy camelCase R code to snake_case?

Rename camelCase functions and variables to snake_case only within files you are already editing, rather than renaming everything at once. Physical data column names from external sources, like B1980_2000, should not be renamed.

Does this R style guide apply to Python code?

No, the standard covers only .R, .Rmd, and .qmd files. Python work follows a separate uv-based convention and is explicitly out of scope.

How should R scripts handle credentials for Google Cloud Storage?

Use Application Default Credentials (ADC) with googleCloudStorageR instead of key files, and never write secrets or tokens into code or logs. Machine-specific paths should go into config or environment variables, not the source.