본문으로 건너뛰기
cccskills
무료GitHub에 공개

tidyverse

R data manipulation with dplyr, tidyr, readr, purrr, stringr, forcats, lubridate. Verb pipelines, reshaping, joins, string/date ops, parquet via arrow. Includes data.table for performance. Use when execution language is R. Python equivalent: polars.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf스타 238(GitHub 238 + cccskills 0)
연동 도구Excel

실행 점수 미검증

설치 방법 보기

포함된 파일(11)

  • SKILL.md12.9 KB
  • references/data-table.md6.7 KB
  • references/factors.md6.2 KB
  • references/gotchas.md10.7 KB
  • references/io.md11.7 KB
  • references/joins.md6.6 KB
  • references/purrr-functional.md6.6 KB
  • references/quickstart.md8.9 KB
  • references/reshaping.md8.3 KB
  • references/strings-dates.md8.3 KB
  • references/window-ranking.md6.8 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Tidyverse Skill

R data manipulation with the core tidyverse packages: dplyr (verb-based data transformation), tidyr (reshaping and tidying), readr (fast delimited file I/O), purrr (functional iteration over lists and vectors), stringr (consistent string operations), forcats (factor manipulation for categorical data), and lubridate (date-time parsing and arithmetic). Also covers arrow for parquet I/O and data.table as a high-performance alternative for large datasets. Use when the execution language is R and the task involves data wrangling, reshaping, joining, string processing, date handling, or file I/O. Python equivalent: the polars skill.

What is the Tidyverse?

The tidyverse is a collection of R packages that share a common design philosophy for data science:

  • Verb-based grammar: Operations read as sentences -- filter(), select(), mutate(), summarize() describe what you want to do
  • Pipe-friendly: Every function takes a data frame as its first argument and returns a data frame, enabling |> pipe chains
  • Tidy data: One observation per row, one variable per column -- functions assume this structure
  • Consistent API: Shared conventions across packages (tidyselect helpers, data masking, .data pronoun)
  • Readable pipelines: Code reads top-to-bottom like a recipe, making it self-documenting

The tidyverse is not a single package but a curated set of packages that work together. This skill covers the data manipulation subset; for visualization see the ggplot2 skill; for statistical modeling see the r-stats skill.

Version Notes

Versions installed in the DAAF container (R 4.5.3):

PackageVersionKey Notes
dplyr1.2.1.by inline grouping, reframe(), pick()
tidyr1.3.2pivot_longer()/pivot_wider() with .value sentinel
readr2.2.0Second-edition parser, read_csv() returns tibble
purrr1.2.2list_c(), list_rbind(), list_cbind()
stringr1.6.0Consistent str_* functions wrapping stringi
forcats1.0.1fct_na_value_to_level(), fct_cross()
lubridate1.9.5ymd() family, interval(), date arithmetic
data.table1.18.2.1DT[i, j, by] syntax, fread()/fwrite()
arrow23.0.1.2read_parquet()/write_parquet(), Arrow-dplyr integration

dplyr 1.1+ changes to be aware of:

  • .by argument in mutate(), summarize(), filter(), slice_*() for inline grouping (no group_by() needed)
  • reframe() replaces summarize() when results have multiple rows per group
  • pick() replaces across() inside cur_data() contexts
  • recode_values() for value-matching (simpler than case_when() for direct mappings; supersedes case_match(), which is soft-deprecated as of dplyr 1.2.0)
  • consecutive_id() for run-length grouping
  • join_by() for inequality and overlap joins

How to Use This Skill

Reference File Structure

FilePurposeWhen to Read
quickstart.mdCore verbs: filter, select, mutate, group_by + summarize, arrange, pipeStarting an R data pipeline, basic wrangling
reshaping.mdpivot_longer, pivot_wider, separate, unite, nest/unnestConverting between wide and long formats
joins.mdleft_join, inner_join, anti_join, semi_join, join keys, validationCombining data frames
io.mdParquet via arrow, CSV via readr, Excel via readxl, remote fetching via httr2/glue, data import patternsReading or writing data files, fetching from HTTP APIs
strings-dates.mdstringr ops (str_detect, str_replace, regex), lubridate (ymd, date arithmetic)String processing or date handling
purrr-functional.mdmap/map_dfr/map2, walk, list-columns, nested data patternsIterating over lists or nested data
factors.mdforcats: fct_relevel, fct_reorder, fct_lump, factor orderingCategorical variable manipulation
window-ranking.mdrow_number, lag/lead, cumsum, ntile, rolling operationsWindow functions and ranking within groups
data-table.mddata.table DT[i, j, by] syntax, fread/fwrite, when to prefer over dplyrPerformance-critical operations on large data
gotchas.mdNSE vs data masking, .data pronoun, across() patterns, group_by footgunsDebugging unexpected behavior

Reading Order

  1. New to tidyverse? Start with quickstart.md then io.md
  2. Reshaping data? Read reshaping.md
  3. Combining datasets? Read joins.md
  4. String or date problems? Read strings-dates.md
  5. Performance issues with large data? Read data-table.md
  6. Something not working? Check gotchas.md first

Related Skills

SkillRelationship
polarsPython equivalent -- covers the same data manipulation domain for Python pipelines
data-scientistMethodology routing -- determines which analysis to run; tidyverse implements it
ggplot2Visualization -- takes tidy data produced by tidyverse and creates plots
r-statsStatistical modeling -- lm/glm, sandwich robust SEs, diagnostics; tidyverse prepares data for modeling
fixestFixed effects regression -- high-dimensional FE, IV, DiD; tidyverse prepares data for fixest
r-python-translationCross-language reference -- maps tidyverse to polars for bilingual annotation

Quick Decision Trees

"I need to manipulate data"

Data manipulation task?
├─ Select/drop columns → ./references/quickstart.md (select)
├─ Filter rows → ./references/quickstart.md (filter)
├─ Create/modify columns → ./references/quickstart.md (mutate)
├─ Sort rows → ./references/quickstart.md (arrange)
├─ Aggregate by group → ./references/quickstart.md (group_by + summarize)
├─ Reshape wide to long → ./references/reshaping.md (pivot_longer)
├─ Reshape long to wide → ./references/reshaping.md (pivot_wider)
├─ Join two data frames → ./references/joins.md
├─ Window functions (lag, rank) → ./references/window-ranking.md
└─ Large data performance → ./references/data-table.md

"I need to work with specific types"

Type-specific operation?
├─ String matching/replacement → ./references/strings-dates.md (stringr)
├─ Date parsing/arithmetic → ./references/strings-dates.md (lubridate)
├─ Categorical/factor levels → ./references/factors.md (forcats)
└─ Iterate over lists → ./references/purrr-functional.md (purrr)

"I need to read or write data"

Data I/O?
├─ Read/write parquet (preferred) → ./references/io.md (arrow)
├─ Read/write CSV → ./references/io.md (readr)
├─ Read Excel → ./references/io.md (readxl)
├─ Fetch from HTTP API → ./references/io.md (httr2, glue)
└─ High-speed CSV for large files → ./references/data-table.md (fread)

File-First Execution in Research Workflows

In DAAF research pipelines, R transformations follow the file-first execution protocol -- code is written to .R script files and executed via the run_with_capture.sh wrapper, never run interactively.

The pattern:

  1. Write transformation code to scripts/stage{N}_{type}/{step}_{task-name}.R
  2. Execute via Bash: bash {BASE_DIR}/scripts/run_with_capture.sh {PROJECT_DIR}/scripts/{script_name}.R
  3. run_with_capture.sh detects the .R extension and uses Rscript automatically
  4. stdout/stderr are appended to the script file as comments
  5. If a script fails, create a versioned copy (_a.R, _b.R, etc.) for fixes

Read agent_reference/SCRIPT_EXECUTION_REFERENCE.md for the complete protocol.

R script structure follows DAAF conventions:

# --- Config ---
library(dplyr)
library(arrow)

PROJECT_DIR <- "/daaf/research/YYYY-MM-DD_Project"

# --- Load ---
# INTENT: Load cleaned school-level data for analysis
df <- read_parquet(file.path(PROJECT_DIR, "data", "schools_clean.parquet"))
cat("Loaded:", nrow(df), "rows,", ncol(df), "columns\n")

# --- Transform ---
# INTENT: Calculate poverty rate by state
# ASSUMES: enrollment > 0 for all rows (validated in cleaning)
result <- df |>
  mutate(poverty_rate = frl_count / enrollment) |>
  group_by(state) |>
  summarize(
    avg_poverty = mean(poverty_rate, na.rm = TRUE),
    n_schools = n(),
    .groups = "drop"
  ) |>
  arrange(desc(avg_poverty))

# --- Validate ---
stopifnot(nrow(result) > 0)
stopifnot(all(result$avg_poverty >= 0 & result$avg_poverty <= 1))
cat("States:", nrow(result), "\n")
cat("Range:", range(result$avg_poverty), "\n")

# --- Save ---
write_parquet(result, file.path(PROJECT_DIR, "data", "state_poverty.parquet"))
cat("Saved: state_poverty.parquet\n")

Quick Reference

Essential Setup

library(dplyr)
library(tidyr)
library(readr)
library(stringr)
library(lubridate)
library(arrow)     # for parquet I/O

Core Operations

OperationCodePackage
Filter rows`df> filter(x > 5)`
Select columns`df> select(a, b, c)`
Create column`df> mutate(y = x * 2)`
Sort`df> arrange(desc(x))`
Group + summarize`df> group_by(g)
Rename`df> rename(new = old)`
Distinct rows`df> distinct(a, b)`
Count`df> count(group_col)`
Left join`df1> left_join(df2, by = "key")`
Pivot longer`df> pivot_longer(cols, names_to, values_to)`
Pivot wider`df> pivot_wider(names_from, values_from)`
Read parquetread_parquet("file.parquet")arrow
Write parquetwrite_parquet(df, "file.parquet")arrow
Read CSVread_csv("file.csv")readr
String detectstr_detect(x, "pattern")stringr
Parse dateymd("2024-01-15")lubridate
Native pipe`df> verb1()

The Pipe Operator

R 4.1+ provides the native pipe |> which passes the left-hand side as the first argument to the right-hand side. Use |> (not the magrittr %>%) for all DAAF pipelines:

# Native pipe -- preferred in DAAF
result <- df |>
  filter(year == 2020) |>
  mutate(rate = count / total) |>
  group_by(state) |>
  summarize(avg_rate = mean(rate)) |>
  arrange(desc(avg_rate))

Topic Index

TopicReference File
filter, select, mutate./references/quickstart.md
arrange, group_by, summarize./references/quickstart.md
Pipe operator./references/quickstart.md
slice, distinct, count./references/quickstart.md
across(), pick()./references/quickstart.md
case_when, if_else./references/quickstart.md
pivot_longer./references/reshaping.md
pivot_wider./references/reshaping.md
separate, unite./references/reshaping.md
nest, unnest./references/reshaping.md
complete, fill./references/reshaping.md
left_join, inner_join./references/joins.md
anti_join, semi_join./references/joins.md
Join keys, by argument./references/joins.md
Join validation./references/joins.md
read_parquet, write_parquet./references/io.md
read_csv, write_csv./references/io.md
Arrow integration./references/io.md
httr2, glue remote fetch./references/io.md
str_detect, str_replace./references/strings-dates.md
str_extract, regex./references/strings-dates.md
ymd, date arithmetic./references/strings-dates.md
Date components./references/strings-dates.md
map, map_dfr, walk./references/purrr-functional.md
List-columns./references/purrr-functional.md
fct_relevel, fct_reorder./references/factors.md
fct_lump, factor ordering./references/factors.md
row_number, lag, lead./references/window-ranking.md
cumsum, ntile./references/window-ranking.md
Rolling operations./references/window-ranking.md
DT[i, j, by] syntax./references/data-table.md
fread, fwrite./references/data-table.md
NSE and data masking./references/gotchas.md
.data pronoun./references/gotchas.md
Common pitfalls./references/gotchas.md

Citation

When this library collection is used as a primary analytical tool, include in the report's Software & Tools references:

Wickham, H. et al. (2019). Welcome to the Tidyverse. Journal of Open Source Software, 4(43), 1686. https://doi.org/10.21105/joss.01686

Cite when: Tidyverse packages are the core data processing engine for the analysis. Do not cite when: Only used for trivial file I/O in a script primarily using another tool.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guide for creating DAAF agent definition files. Covers 12-section template, hook registration, skills-in-frontmatter, integration checklist. Use when adding or revising agents. For SKILL.md files, use skill-authoring instead.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

Researcher-facing analytic triangulation ("creative verification") for stress-testing provisional findings and designing pre-specified challenges before an analysis runs. Turns a researcher's concern or focal claim into competing explanations, bounded discriminating tests, audited diagnostic artifacts, and evidence-calibrated interpretations in a hypothesis/evidence ledger — behavioral, output-level verification replacing line-by-line code review. Covers 12 challenge families organized by Shadish-Cook-Campbell validity type, named sensitivity statistics, pre-committed interpretation rules, anti-fishing guardrails, and interactive diagnostic-artifact QA. Use in Ad Hoc Collaboration to verify, challenge, or stress-test a result, or to design discriminating tests before an analysis runs. Not code-change verification (verify skill / code review) and not final adjudication or re-execution (data-verifier, Reproducibility Verification) — prospective, hypothesis-driven challenge design of analytic claims.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

In-situ smoke testing that verifies a LIVE DAAF deployment functions end-to-end in whatever provider route it is configured for. Auto-detects the active install route (anthropic-subscription, openrouter, chatgpt-subscription shim, openai-api shim) and runs tiered probes: Tier 0 free preflight (route/env coherence, hooks, statuslines, shim health); Tier 1 one live round-trip (~cents); Tier 2 a six-probe functional battery (dispatch, coding, web, skill loading, isolation-strip, nested-dispatch deny); Tier D a zero-cost deterministic battery (bats, Pester, lint, safety-hook tests). Use after install, after a rebuild or update, after any provider/config change (new API key, model remap, shim change), for pre-release validation, or when asked "is my install working" or to "smoke test the deployment/config." Requires the DAAF_DEV=1 dev image; a contributor tool, not end-user-facing. NOT DAAFBench (model behavioral-adherence evaluation under benchmarks/) and NOT scripts/smoke_tests/ (R/Python library-package smoke tests).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

Operational framework for the DAAF orchestrator. Defines engagement modes, confirmation protocol, subagent dispatch, context budget, and reference-loading. Loaded exclusively by the orchestrator — not for subagents or user questions.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

Data science methodology and method-selection routing for quantitative research. Covers EDA, data validation, descriptive analysis, causal inference (IV, DiD, RD, synthetic control), clustering/PCA/UMAP, supervised ML, geospatial analysis, network analysis, and visualization design. Contains the canonical method-to-library routing tree, routed by execution language — Python: statsmodels (OLS/GLM/time series), pyfixest (FE/DiD), linearmodels (RE/GMM/SUR), svy (complex surveys), scikit-learn (clustering/prediction ML), geopandas (spatial), igraph (network analysis); R: r-stats (OLS/GLM/time series), fixest (FE/DiD), plm (panel/RE/IV), survey-r (complex surveys), tidymodels (ML), sf-terra (spatial), igraph-r (network analysis). Load the routed tool-specific skill before giving tool-specific advice or writing code — library skills encode environment constraints and curated caveats absent from general knowledge.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

Interpretation guidance for Urban Institute Education Data Portal datasets. The Portal is a curation layer over federal data: lowercase variable names, integer-encoded categoricals, standardized missing codes (-1 missing, -2 not applicable, -3 suppressed). Covers year definitions, grade encoding (grade=-1 is Pre-K, not missing), suppression rates, ODC-By licensing, and cross-source join identifiers. Load before analyzing any Portal data. Routes to source-specific deep-dive skills for individual datasets.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DAAF-Contribution-Community/daaf2382026년 10월 17일 업데이트

DAAF-Contribution-Community의 스킬 모두 보기

이 스킬의 문제 신고