MCP HubMCP Hub
스킬 목록으로 돌아가기

generate-statistical-tables

pjt222
업데이트됨 2 days ago
1 조회
17
2
17
GitHub에서 보기
메타worddesign

정보

이 스킬은 gt, kableExtra 또는 flextable을 사용하여 R에서 출판용 통계 표를 생성합니다. 기술 통계량, 회귀 분석 결과, ANOVA 표, 상관 행렬을 APA 형식으로 작성합니다. 학술 논문, 보고서 또는 Quarto/R 마크다운 문서를 위한 표를 준비할 때 사용하세요.

빠른 설치

Claude Code

추천
기본
npx skills add pjt222/agent-almanac -a claude-code
플러그인 명령대체
/plugin add https://github.com/pjt222/agent-almanac
Git 클론대체
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/generate-statistical-tables

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

統計表の生成

Create publication-ready statistical tables for reports and manuscripts.

使用タイミング

  • Creating descriptive statistics tables
  • Formatting regression or ANOVA output
  • Building correlation matrices
  • Producing APA-style tables for academic papers
  • Generating tables for Quarto/R Markdown documents

入力

  • 必須: Statistical analysis results (model objects, summary data)
  • 必須: Output format (HTML, PDF, Word)
  • 任意: Style guide (APA, journal-specific)
  • 任意: Table numbering scheme

手順

ステップ1: Choose Table Package

PackageBest forFormats
gtHTML, general-purposeHTML, PDF, Word
kableExtraLaTeX/PDF documentsPDF, HTML
flextableWord documentsWord, PDF, HTML
gtsummaryClinical/statistical summariesAll via gt/flextable

期待結果: A table package selected based on the output format and use case. The chosen package is installed and loadable.

失敗時: If the required package is not installed, run install.packages("gt") (or the appropriate package). For gtsummary, both gt and gtsummary must be installed.

ステップ2: Descriptive Statistics Table

library(gt)

descriptives <- data |>
  group_by(group) |>
  summarise(
    n = n(),
    M = mean(score, na.rm = TRUE),
    SD = sd(score, na.rm = TRUE),
    Min = min(score, na.rm = TRUE),
    Max = max(score, na.rm = TRUE)
  )

gt(descriptives) |>
  tab_header(
    title = "Table 1",
    subtitle = "Descriptive Statistics by Group"
  ) |>
  fmt_number(columns = c(M, SD), decimals = 2) |>
  fmt_number(columns = c(Min, Max), decimals = 1) |>
  cols_label(
    group = "Group",
    n = md("*n*"),
    M = md("*M*"),
    SD = md("*SD*")
  )

期待結果: A gt table object with formatted means, SDs, and counts grouped by category. Column headers use proper statistical notation (italicized M, SD, n).

失敗時: If group_by() produces unexpected results, verify the grouping variable exists and has the expected levels. If fmt_number() throws an error, ensure the target columns contain numeric data.

ステップ3: Regression Results Table

model <- lm(outcome ~ predictor1 + predictor2 + predictor3, data = data)

library(gtsummary)

tbl_regression(model) |>
  bold_p() |>
  add_glance_source_note(
    include = c(r.squared, adj.r.squared, nobs)
  ) |>
  modify_header(label = "**Predictor**") |>
  modify_caption("Table 2: Regression Results")

期待結果: A gtsummary regression table with bolded p-values, model fit statistics (R-squared, N) in a source note, and a descriptive caption.

失敗時: If tbl_regression() fails, verify the input is a model object (e.g., lm, glm). If add_glance_source_note() errors, check that broom can tidy the model: broom::glance(model).

ステップ4: Correlation Matrix

library(gt)

cor_matrix <- cor(data[, c("var1", "var2", "var3", "var4")],
                  use = "pairwise.complete.obs")

# Format lower triangle
cor_matrix[upper.tri(cor_matrix)] <- NA

as.data.frame(cor_matrix) |>
  tibble::rownames_to_column("Variable") |>
  gt() |>
  fmt_number(decimals = 2) |>
  sub_missing(missing_text = "") |>
  tab_header(title = "Table 3", subtitle = "Correlation Matrix")

期待結果: A lower-triangle correlation matrix rendered as a gt table with blanked upper triangle, two decimal places, and a clear caption.

失敗時: If sub_missing() does not blank the upper triangle, verify that NA values were set correctly with cor_matrix[upper.tri(cor_matrix)] <- NA. If variables are non-numeric, cor() will fail; filter to numeric columns first.

ステップ5: ANOVA Table

aov_result <- aov(score ~ group * condition, data = data)

library(gtsummary)

tbl_anova <- broom::tidy(aov_result) |>
  gt() |>
  fmt_number(columns = c(sumsq, meansq, statistic), decimals = 2) |>
  fmt_number(columns = p.value, decimals = 3) |>
  cols_label(
    term = "Source",
    df = md("*df*"),
    sumsq = md("*SS*"),
    meansq = md("*MS*"),
    statistic = md("*F*"),
    p.value = md("*p*")
  ) |>
  tab_header(title = "Table 4", subtitle = "ANOVA Results")

期待結果: A formatted ANOVA table with Source, df, SS, MS, F, and p columns. Interaction terms are clearly labeled and p-values are formatted to three decimal places.

失敗時: If broom::tidy(aov_result) produces unexpected columns, verify the model is an aov object. For Type III sums of squares, use car::Anova(model, type = 3) instead of base aov().

ステップ6: Save Tables

# Save as HTML
gtsave(my_table, "table1.html")

# Save as Word
gtsave(my_table, "table1.docx")

# Save as PNG image
gtsave(my_table, "table1.png")

# For LaTeX/PDF (kableExtra)
kableExtra::save_kable(kable_table, "table1.pdf")

期待結果: Table saved to the specified file format (HTML, Word, PNG, or PDF). The output file opens correctly in the appropriate application.

失敗時: If gtsave() fails for Word format, ensure the webshot2 package is installed. For PDF output via kableExtra, ensure a LaTeX distribution (TinyTeX or MiKTeX) is installed.

ステップ7: Embed in Quarto Document

```{r}
#| label: tbl-descriptives
#| tbl-cap: "Descriptive Statistics by Group"

gt(descriptives) |>
  fmt_number(columns = c(M, SD), decimals = 2)
```

See @tbl-descriptives for summary statistics.

期待結果: The table renders inline in the Quarto document with a cross-referenceable label (@tbl-*) and a proper caption. The table adapts to the document's output format automatically.

失敗時: If the table does not render, verify the chunk label starts with tbl- for Quarto cross-referencing. If formatting is lost in PDF, switch from gt to kableExtra for LaTeX-based output.

バリデーション

  • Table renders correctly in target format (HTML, PDF, Word)
  • Numbers are formatted consistently (decimal places, alignment)
  • Statistical notation follows the style guide (italicized, proper symbols)
  • Table has a clear caption and numbering
  • Column headers are meaningful
  • Notes/footnotes explain abbreviations or significance markers

よくある落とし穴

  • gt in PDF: gt has limited PDF support. Use kableExtra for LaTeX-heavy documents.
  • Rounding inconsistency: Always use fmt_number() (gt) or format() rather than round() for display
  • Missing values display: Configure with sub_missing() in gt or options(knitr.kable.NA = "")
  • Wide tables in PDF: Tables exceeding page width need landscape() or font size reduction
  • APA number formatting: No leading zero for values bounded by 1 (p-values, correlations): ".03" not "0.03"

関連スキル

  • format-apa-report - tables within APA manuscripts
  • create-quarto-report - embedding tables in reports
  • build-parameterized-report - tables that adapt to parameters

GitHub 저장소

pjt222/agent-almanac
경로: i18n/ja/skills/generate-statistical-tables
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

연관 스킬

content-collections

메타

이 스킬은 콘텐츠 콜렉션(Content Collections)을 위한 프로덕션 검증된 설정을 제공합니다. 콘텐츠 콜렉션은 Markdown/MDX 파일을 Zod 검증이 포함된 타입 안전한 데이터 콜렉션으로 변환해주는 TypeScript 최우선 도구입니다. 블로그, 문서 사이트 또는 콘텐츠 중심의 Vite + React 애플리케이션을 구축할 때 타입 안전성과 자동 콘텐츠 검증을 보장하기 위해 사용하세요. Vite 플러그인 구성과 MDX 컴파일부터 배포 최적화 및 스키마 검증에 이르기까지 모든 것을 다룹니다.

스킬 보기

polymarket

메타

이 스킬은 개발자들이 Polymarket 예측 시장 플랫폼을 활용한 애플리케이션을 구축할 수 있도록 지원하며, 거래 및 시장 데이터를 위한 API 통합 기능을 포함합니다. 또한 WebSocket을 통한 실시간 데이터 스트리밍을 제공하여 실시간 거래와 시장 활동을 모니터링할 수 있습니다. 이를 통해 거래 전략을 구현하거나 실시간 시장 업데이트를 처리하는 도구를 생성하는 데 활용할 수 있습니다.

스킬 보기

creating-opencode-plugins

메타

이 스킬은 개발자들이 명령어, 파일, LSP 작업 등 25개 이상의 이벤트 유형에 연결되는 OpenCode 플러그인을 만들 수 있도록 돕습니다. JavaScript/TypeScript 모듈을 위한 플러그인 구조, 이벤트 API 명세, 구현 패턴을 제공합니다. OpenCode AI 어시스턴트의 라이프사이클을 사용자 정의 이벤트 기반 로직으로 가로채거나, 모니터링하거나, 확장해야 할 때 사용하세요.

스킬 보기

sglang

메타

SGLang은 RadixAttention 프리픽스 캐싱을 활용하여 JSON, 정규식, 에이전트 워크플로우를 위한 고속 구조화 생성에 특화된 고성능 LLM 서빙 프레임워크입니다. 특히 반복되는 프리픽스가 있는 작업에서 상당히 빠른 추론 속도를 제공하여 복잡한 구조화 출력 및 다중 턴 대화에 이상적입니다. 제약 디코딩이 필요하거나 광범위한 프리픽스 공유가 있는 애플리케이션을 구축할 때는 vLLM과 같은 대안보다 SGLang을 선택하십시오.

스킬 보기