Skip to content
Back to skills

Gt

ASecurity

R gt package for grammar of tables. Use for creating publication-quality tables.

  • 5 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 8, 2026
data

Security analysis

A100/100

Scanned September 8, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill gt --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gt?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Gt
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-r-analytics-skill/badge)](https://www.skillsdirectory.com/skills/leolin990405-r-analytics-skill)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: gt
description: R gt package for grammar of tables. Use for creating publication-quality tables.
---

# gt

Easily create presentation-ready display tables.

## Basic Table

```r
library(gt)

# Create gt table
mtcars %>%
  head() %>%
  gt()

# From data frame
gt(df)
```

## Structure

```r
df %>%
  gt(rowname_col = "name") %>%
  tab_header(
    title = "Table Title",
    subtitle = "Subtitle here"
  ) %>%
  tab_source_note("Source: Dataset") %>%
  tab_footnote(
    footnote = "Note about data",
    locations = cells_body(columns = col1, rows = 1)
  )
```

## Column Labels

```r
df %>%
  gt() %>%
  cols_label(
    col1 = "Column 1",
    col2 = "Column 2"
  ) %>%
  cols_move_to_start(col2) %>%
  cols_hide(col3)
```

## Formatting

```r
df %>%
  gt() %>%
  fmt_number(columns = value, decimals = 2) %>%
  fmt_currency(columns = price, currency = "USD") %>%
  fmt_percent(columns = pct, decimals = 1) %>%
  fmt_date(columns = date, date_style = "yMMMd")
```

## Styling

```r
df %>%
  gt() %>%
  tab_style(
    style = cell_fill(color = "lightblue"),
    locations = cells_body(columns = col1)
  ) %>%
  tab_style(
    style = cell_text(weight = "bold"),
    locations = cells_column_labels()
  )
```

## Conditional Formatting

```r
df %>%
  gt() %>%
  data_color(
    columns = value,
    colors = scales::col_numeric(
      palette = c("red", "white", "green"),
      domain = NULL
    )
  )
```

## Grouping

```r
df %>%
  gt(groupname_col = "group") %>%
  tab_spanner(
    label = "Measurements",
    columns = c(col1, col2)
  )
```

## Summary Rows

```r
df %>%
  gt(groupname_col = "group") %>%
  summary_rows(
    groups = TRUE,
    columns = value,
    fns = list(
      Total = ~sum(.),
      Average = ~mean(.)
    )
  ) %>%
  grand_summary_rows(
    columns = value,
    fns = list(Grand = ~sum(.))
  )
```

## Export

```r
# Save as HTML
gtsave(table, "table.html")

# Save as PNG
gtsave(table, "table.png")

# Save as PDF
gtsave(table, "table.pdf")

# Save as RTF
gtsave(table, "table.rtf")
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in data →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.