Skip to content
Back to skills

Targets

ASecurity

R targets package for pipeline workflows. Use for creating reproducible, Make-like data analysis pipelines.

  • 5 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added June 5, 2026
data

Security analysis

A100/100

Scanned June 5, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Targets?

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

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

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: targets
description: R targets package for pipeline workflows. Use for creating reproducible, Make-like data analysis pipelines.
---

# targets

Make-like pipeline tool for data science.

## Basic Setup

```r
# _targets.R file in project root
library(targets)

# Define targets
list(
  tar_target(data, read_csv("data.csv")),
  tar_target(model, fit_model(data)),
  tar_target(report, render_report(model))
)
```

## Running Pipelines

```r
library(targets)

# Run pipeline
tar_make()

# Run specific target
tar_make(names = model)

# Parallel execution
tar_make_future(workers = 4)

# Check status
tar_manifest()
tar_visnetwork()
```

## Target Types

```r
list(
  # Standard target
  tar_target(data, load_data()),

  # File target (tracks file changes)
  tar_target(
    raw_file,
    "data/raw.csv",
    format = "file"
  ),

  # Multiple files
  tar_target(
    files,
    list.files("data", full.names = TRUE),
    format = "file"
  ),

  # RDS format (default)
  tar_target(model, fit_model(data), format = "rds"),

 # Feather format
  tar_target(df, process_data(data), format = "feather"),

  # Parquet format
  tar_target(df, process_data(data), format = "parquet")
)
```

## Branching (Dynamic)

```r
list(
  # Create branches dynamically
  tar_target(
    files,
    list.files("data", pattern = "*.csv", full.names = TRUE)
  ),

  # Map over files
  tar_target(
    processed,
    process_file(files),
    pattern = map(files)
  ),

  # Combine results
  tar_target(
    combined,
    bind_rows(processed)
  )
)
```

## Branching (Static)

```r
# In _targets.R
values <- list(
  list(name = "model_a", params = list(alpha = 0.1)),
  list(name = "model_b", params = list(alpha = 0.5))
)

list(
  tar_map(
    values = values,
    tar_target(model, fit_model(data, params))
  )
)
```

## Dependencies

```r
list(
  tar_target(raw_data, read_csv("data.csv")),
  tar_target(clean_data, clean(raw_data)),
  tar_target(model, fit(clean_data)),
  tar_target(predictions, predict(model, clean_data)),
  tar_target(report, render("report.Rmd", predictions))
)

# targets automatically detects dependencies
# from function arguments
```

## Inspection

```r
# View pipeline
tar_visnetwork()

# Check outdated targets
tar_outdated()

# Read target value
tar_read(model)

# Load target into environment
tar_load(model)

# Get metadata
tar_meta()
```

## Error Handling

```r
list(
  tar_target(
    risky_target,
    risky_function(),
    error = "continue"  # Continue on error
  ),

  tar_target(
    safe_target,
    safe_function(),
    error = "stop"  # Stop on error (default)
  )
)
```

## Caching

```r
# Targets are cached automatically
# Re-run only rebuilds changed targets

# Force rebuild
tar_invalidate(model)

# Delete cache
tar_destroy()

# Prune unused targets
tar_prune()
```

## Configuration

```r
# _targets.R
tar_option_set(
  packages = c("dplyr", "ggplot2"),
  format = "rds",
  memory = "transient",
  garbage_collection = TRUE
)

list(
  tar_target(data, load_data()),
  tar_target(plot, make_plot(data))
)
```

## Reports

```r
list(
  tar_target(data, load_data()),
  tar_target(model, fit_model(data)),

  # Render R Markdown
  tar_render(
    report,
    "report.Rmd",
    output_file = "output/report.html"
  ),

  # Render Quarto
  tar_quarto(
    quarto_report,
    "report.qmd"
  )
)
```

## Best Practices

```r
# 1. Keep functions in R/ directory
# 2. Source functions in _targets.R
source("R/functions.R")

# 3. Use tar_option_set for common settings
tar_option_set(packages = c("tidyverse"))

# 4. Name targets descriptively
list(
  tar_target(raw_sales_data, read_sales()),
  tar_target(clean_sales_data, clean_sales(raw_sales_data)),
  tar_target(sales_model, fit_sales_model(clean_sales_data))
)
```

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.