# Data Table

> R data.table package for fast data manipulation. Use for high-performance data operations with concise syntax.

- **Type:** Skill
- **Install:** `agentstack add skill-leolin990405-r-analytics-skill-data-table`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [LeoLin990405](https://agentstack.voostack.com/s/leolin990405)
- **Installs:** 0
- **Category:** [Data & Analytics](https://agentstack.voostack.com/c/data-and-analytics)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [LeoLin990405](https://github.com/LeoLin990405)
- **Source:** https://github.com/LeoLin990405/r-analytics-skill/tree/main/sub-skills/r-data/r-data-manipulation/data.table

## Install

```sh
agentstack add skill-leolin990405-r-analytics-skill-data-table
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# data.table

High-performance data manipulation.

## Basics

```r
library(data.table)

# Create
dt  3]
dt[x > 3 & y == "a"]
dt[x %in% c(1, 2, 3)]
dt[x %between% c(2, 4)]
dt[y %like% "^a"]

# Order
dt[order(x)]
dt[order(-x)]
dt[order(x, -y)]

# First/last rows
dt[1:5]
dt[.N]  # Last row
dt[(.N-4):.N]  # Last 5 rows
```

## Column Operations (j)

```r
# Select columns
dt[, .(x, y)]
dt[, x]  # Returns vector
dt[, .(x)]  # Returns data.table
dt[, c("x", "y"), with = FALSE]

# Compute
dt[, .(mean_x = mean(x), sum_y = sum(y))]
dt[, .(total = x + y)]

# Modify in place (:=)
dt[, z := x * 2]
dt[, c("a", "b") := .(x + 1, y)]
dt[, `:=`(a = x + 1, b = y)]

# Remove columns
dt[, z := NULL]
dt[, c("a", "b") := NULL]

# Special symbols
dt[, .N]  # Number of rows
dt[, .I]  # Row indices
dt[, .SD]  # Subset of data
dt[, .SDcols]  # Columns in .SD
```

## Grouping (by)

```r
# Group by
dt[, .(mean = mean(x)), by = category]
dt[, .(mean = mean(x)), by = .(cat1, cat2)]

# keyby (sorted)
dt[, .(mean = mean(x)), keyby = category]

# .SD operations
dt[, lapply(.SD, mean), by = category]
dt[, lapply(.SD, mean), by = category, .SDcols = c("x", "y")]
dt[, lapply(.SD, mean), by = category, .SDcols = is.numeric]

# .N by group
dt[, .N, by = category]
```

## Keys and Joins

```r
# Set key
setkey(dt, id)
setkeyv(dt, c("id1", "id2"))

# Join
dt1[dt2, on = "id"]  # Right join
dt2[dt1, on = "id"]  # Left join
dt1[dt2, on = "id", nomatch = 0]  # Inner join

# Multiple keys
dt1[dt2, on = .(a, b)]
dt1[dt2, on = .(a = x, b = y)]

# Non-equi joins
dt1[dt2, on = .(x >= a, x  0][order(-y)][, .(mean = mean(x)), by = cat]

# Or with line breaks
dt[x > 0
  ][order(-y)
  ][, .(mean = mean(x)), by = cat]
```

## Performance

```r
# Set index (secondary key)
setindex(dt, col)

# fread/fwrite (fast I/O)
dt <- fread("file.csv")
fwrite(dt, "output.csv")

# Modify by reference
set(dt, i = 1L, j = "x", value = 100)
setnames(dt, "old", "new")
setcolorder(dt, c("b", "a", "c"))
```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [LeoLin990405](https://github.com/LeoLin990405)
- **Source:** [LeoLin990405/r-analytics-skill](https://github.com/LeoLin990405/r-analytics-skill)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-leolin990405-r-analytics-skill-data-table
- Seller: https://agentstack.voostack.com/s/leolin990405
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
