repo_put: Create a new item in the repository.

Description Usage Arguments Details Value See Also Examples

View source: R/repo_public.R

Description

Given an R object, stores it to an RDS file in the repo root and add an associated item to the repo index, including object name, description, tags and more.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
repo_put(
  obj,
  name = NULL,
  description = NULL,
  tags = NULL,
  prj = NULL,
  src = NULL,
  chunk = name,
  depends = NULL,
  replace = F,
  asattach = F,
  to = NULL,
  addversion = F,
  URL = NULL,
  checkRelations = T
)

Arguments

obj

An R object to store in the repo.

name

A character identifier for the new item. If NULL, the name of the obj variable will be used.

description

A character description of the item.

tags

A list of tags to sort the item. Tags are useful for selecting sets of items and run bulk actions.

prj

The name of a project item in the repository (see project). Default is no associated project item.

src

Name of an existing item to be annotated as the "generator" of the new item. Usually it is an attachment item containing the source code that generated the new item. Default is NULL.

chunk

The name of the code chunk within src that is responsible for building the item. Set to name by default. See build.

depends

Character vector: items that depend on this item. Default is NULL.

replace

One of: V, F, "addversion" to define behavior when an item by the same name exists. If V, overwrite it. If F stop with an error. If "addversion" the new item is stored as a new version and the old item is renamed by appending a "#N" suffix. Default is F.

asattach

Specifies that the item is to be treated as an attachment (see attach). Default is F.

to

Vector of character. Specifies which item this item is attached to. Default is NULL.

addversion

Deprecated, use the replace parameter instead.

URL

Remote URL where the pull function expects to download actual item data from. Default is NULL.

checkRelations

Check if items referenced by this item exist. Default is T.

Details

The item name can be any string, however it should be a concise identifier, possibly without special character (could become mandatory soon). Some tags have a special meaning, like "hide" (do not show the item by default), "attachment" (the item is an attachment - this should never be set manually), "stash" (the item is a stashed item, makes the item over-writable by other "stash" items by default).

Value

Used for side effects.

See Also

get, set, attach, info

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Repository creation
rp_path <- file.path(tempdir(), "example_repo")
rp <- repo_open(rp_path, TRUE)

## Producing some irrelevant data
data1 <- 1:10
data2 <- data1 * 2
data3 <- data1 / 2

## Putting the data in the database, specifying dependencies
rp$put(
    obj = data1,
    name = "item1",
    description = "First item",
    tags = c("repo_put", "a_random_tag"),
    )
rp$put(data2, "item2", "Item dependent on item1",
    "repo_dependencies", depends="item1")
rp$put(data3, "item3", "Item dependent on item1 and item2",
    "repo_dependencies", depends=c("item1", "item2"))

print(rp)

## Creating another version of item1
data1.2 <- data1 + runif(10)
rp$put(data1.2, name = "item1", "First item with additional noise",
    tags = c("repo_put", "a_random_tag"), replace="addversion")
print(rp, all=TRUE)
rp$info("item1#1")

## wiping temporary repo
unlink(rp_path, TRUE)

franapoli/repo documentation built on May 17, 2021, 7:24 p.m.