Learn R Programming

tarchives

Overview

The goal of tarchives is to make targets pipelines into a package. It runs targets pipeline in /inst/tarchives and stores the results in the R user directory. This means that the user does not have to run the process repeatedly, and the developer has the flexibility to update the data as versions are updated.

This package is a wrapper for the targets package and contains the following functions:

  • tar_archive(): Convert the targets function to tarchives version
  • tar_make_archive(): tarchives version of targets::tar_make() function
  • tar_read_archive(): tarchives version of targets::tar_read() function
  • tar_target_archive(): tarchives version of targets::tar_target() function

Installation

install.packages("tarchives")

Development version

You can install the development version of tarchives from GitHub with:

install.packages("pak")
pak::pak("UchidaMizuki/tarchives")

Usage

To use tarchives, run the following code under the package you are developing:

library(tarchives)
use_tarchives()

This will create an inst/tarchives directory in your package, where your target pipelines will be stored. You can define your target pipeline in the _targets.R file in the inst/tarchives/example-model directory as follows:

# inst/tarchives/example-model/_targets.R
library(targets)

list(
  tar_target(
    data,
    iris[iris$Species != "setosa", ]
  ),
  tar_target(
    model,
    lm(Sepal.Width ~ Sepal.Length, data)
  )
)

If you have created a package called your-package and saved the pipeline to a directory called example-model in the inst/tarchives directory, you can run it using the following command:

tar_make_archive(
  package = "your-package",
  pipeline = "example-model"
)

Then you can read the results using the tar_read_archive() function:

tar_read_archive(
  model,
  package = "your-package",
  pipeline = "your-pipeline"
)
#> 
#> Call:
#> lm(formula = Sepal.Width ~ Sepal.Length, data = data)
#> 
#> Coefficients:
#>  (Intercept)  Sepal.Length  
#>        1.131         0.278

Declare a target from another pipeline

You can also declare a target from another pipeline using the tar_target_archive() function. For example, if you want to declare the data and model targets from the example-model pipeline in your _targets.R file, you can do it as follows:

library(targets)

tar_source()

list(
  tarchives::tar_target_archive(
    data,
    package = "tarchives",
    pipeline = "example-model"
  ),
  tarchives::tar_target_archive(
    model,
    package = "tarchives",
    pipeline = "example-model"
  )
)

Copy Link

Version

Install

install.packages('tarchives')

Version

0.1.0

License

MIT + file LICENSE

Maintainer

Mizuki Uchida

Last Published

June 4th, 2025

Functions in tarchives (0.1.0)

tar_source_archive

Run archived R scripts.
use_tarchives

Use tarchives
tar_read_archive

Read a target's value from archive storage
tar_archive_store

Path to the archived target store directory
tar_archive

Function factory for archived targets
tar_make_archive

Run an archived pipeline of targets.
tar_archive_script

Path to the archived target script file
tar_target_archive

Declare a target to read an archive.
tarchives-package

tarchives: Make Your 'targets' Pipelines into a Package