# Retrieve or Inspect Registered Data

Datamonger for R · 0.2.0

[Source](<https://github.com/jolars/datamonger/blob/fbf4417f4d75b63acbb7eb39975add7aedbff2f6/packages/r/R/api.R>)

```r
fetch_artifact(
    name,
    source = NULL,
    version = NULL,
    artifact = NULL,
    registry = NULL,
    cache_dir = NULL,
    offline = FALSE
)
```

<a id="retrieve-or-inspect-registered-data"></a>

## Retrieve or Inspect Registered Data

Resolve a dataset within one strongly selected registry. Artifact size and
SHA-256 verification cannot be disabled. Decoded verification is enabled by
default and may be disabled only explicitly.


<a id="usage"></a>

## Usage

```r
fetch_data(
  name,
  source = NULL,
  version = NULL,
  registry = NULL,
  cache_dir = NULL,
  offline = FALSE,
  verify_decoded = TRUE,
  return_info = FALSE
)
```

```r
fetch_artifact(
  name,
  source = NULL,
  version = NULL,
  artifact = NULL,
  registry = NULL,
  cache_dir = NULL,
  offline = FALSE
)
```

```r
data_info(
  name,
  source = NULL,
  version = NULL,
  registry = NULL,
  cache_dir = NULL,
  offline = FALSE
)
```

```r
list_data(registry = NULL, cache_dir = NULL, offline = FALSE)
```

<a id="arguments"></a>

## Arguments

`name`

A bare dataset name, `source:name`, or `source:name@version`.

`source`

The dataset source. Required for bare names; omit it for
qualified references, even if the values would agree.

`version`

An exact version. Omit it when the reference embeds a version,
even if the values would agree. If neither form supplies a version, resolve
the registry default.

`registry`

A strong selector, or `NULL` for the active selector.

`cache_dir`

An explicit cache path, or `NULL` for the platform default.

`offline`

Whether to forbid all network access.

`verify_decoded`

Whether to verify expected shape and canonical digest.

`return_info`

Whether to return reproducibility metadata with the data.

`artifact`

An artifact name. It may be omitted for a single-artifact
dataset.

<a id="value"></a>

## Value

`fetch_data()` returns a graph, hypergraph, data frame, Datamonger sparse
result, or `datamonger_dataset_splits` named list in provider split order.
With `return_info = TRUE`, it returns a `datamonger_fetch_result`.
`fetch_artifact()` returns a cache path. Metadata functions return one or a
list of `datamonger_data_info` records. Sparse features use a row-compressed
`Matrix`, or an exact `datamonger_csr_matrix` when a declared dimension
exceeds the `Matrix` integer limit.


<a id="details"></a>

## Details

Named splits use manifest schema 4. Access them with `data[["validation"]]`.
Each value is a table or sparse dataset, and a feature-only test table has no
response column. Split names and row membership are preserved exactly.


Multilabel results have sparse `features` and `response` matrices and a
`label_index_base`. Source label `k` maps to column
`k - label_index_base + 1`.


Sparse label joins return named train and test splits. Each split also
contains the row-aligned `document_id` vector and the `label_codes` vector
in response column order.


Ranking results have class `datamonger_ranking_sparse_dataset` and contain
sparse `features`, a relevance vector `response`, and a row-aligned int64
vector `query_id`.


Metadata records expose `preprocessing` when recorded in a version 3
registry. Upstream processing and Datamonger preparation have separate
stages, with status `unknown`, `none`, or `documented`. Known steps retain
their order, string parameters, and evidence references. Missing history is
`NULL`. These records describe the registered artifacts; fetching does not
apply the transformations.


Graphs return a `datamonger_graph_dataset` with `directed`, `nodes`, and
`edges`. A `datamonger_hypergraph_dataset` has `directed`, `nodes`,
`hyperedges`, and `incidences`. Each topology table is a data frame.


<a id="examples"></a>

## Examples

```r
cache <- tempfile("datamonger-cache-")
registry <- active_registry(project_dir = tempdir())
datasets <- list_data(registry = registry, cache_dir = cache, offline = TRUE)
length(datasets)
data_info("uci:iris", registry = registry, cache_dir = cache, offline = TRUE)


# \dontrun

# These calls may download the dataset.
path <- fetch_artifact("uci:iris", registry = registry, cache_dir = cache)
head(fetch_data("uci:iris", registry = registry, cache_dir = cache))

unlink(cache, recursive = TRUE)
```

```text
[1] 57
```

```text
<datamonger_data_info>uci:iris@1
  Iris
  registry: 1.7.0
```

## Same API in

- [Datamonger for Julia: `Datamonger.fetch_artifact`](<../../julia/reference/8f044e42bb5076b809054741f549900268de36f7361b04c854d1de37000e4ad4>)
- [Datamonger for Python: `datamonger.fetch_artifact`](<../../python/reference/7e4c11a8709812857eb6337c5260f8a7b2c3ecfc6b067f29b65cc96558a0d164>)
