# Table

## *class* <mark style="color:purple;">Table</mark>

Tables are the fundamental data-containing entity in Redivis. Various methods on this class allow you to read data from Redivis tables into R.

## Examples

{% tabs %}
{% tab title="Read data" %}

```r
library("redivis")

# Specify the table's container, either a dataset or workflow
dataset <- redivis$organization("Demo")$dataset("iris_species")

table <- dataset$table("Iris")
table$to_tibble()
# 	Id	SepalLengthCm	SepalWidthCm	PetalLengthCm	PetalWidthCm	Species
# 0	33	5.2	        4.1	        1.5	        0.1	        Iris-setosa
# ...

# Other methods to read data:
# table$to_arrow_batch_reader()
# table$to_arrow_dataset()
# table$to_arrow_dataset()
# table$to_data_frame()
# table$to_data_table()
# table$to_sf_tibble()
```

{% endtab %}

{% tab title="Download files" %}

<pre class="language-r"><code class="lang-r">library("redivis")

<strong>dataset &#x3C;- redivis$user("demo")$dataset("Example non-tabular files")
</strong>table &#x3C;- dataset$table("tiffs")

table$download_files("/path/to/directory", overwrite=TRUE)
</code></pre>

{% endtab %}
{% endtabs %}

## Constructors

<table data-header-hidden><thead><tr><th width="312">Method</th><th>Description</th></tr></thead><tbody><tr><td><a href="redivis/redivisusdtable"><strong><code>redivis$table</code></strong></a>(reference)</td><td>Return a Table within the <a href="..#environment-variables">current default scope</a> (either a dataset or workflow). In a Redivis notebook, the default scope will always be the notebook's workflow.</td></tr><tr><td><a href="dataset/datasetusdtable"><strong><code>Dataset$table</code></strong></a>(reference)</td><td>Return a Table within a specific <a href="dataset">dataset</a>.</td></tr><tr><td><a href="workflow/workflowusdtable"><strong><code>Workflow$table</code></strong></a>(reference)</td><td>Return a Table within a specific <a href="workflow">workflow</a>.</td></tr></tbody></table>

## Attributes

| **`properties`** | A named list containing the [API resource representation of the table](https://docs.redivis.com/api/resource-definitions/table#base-definition). This will only be populated after one of the table methods that read data are called. |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

## Methods

<table data-header-hidden><thead><tr><th width="441"></th><th></th></tr></thead><tbody><tr><td><strong>Reading data and metadata</strong></td><td></td></tr><tr><td><a href="table/tableusddownload"><strong><code>Table$download</code></strong></a>([path, format, ...])</td><td>Export a table in a particular format and download it to disk.</td></tr><tr><td><a href="table/tableusdexists"><strong><code>Table$exists</code></strong></a>()</td><td>Check whether the table exists</td></tr><tr><td><a href="table/tableusdfile"><strong><code>Table$file</code></strong></a>(name, [...])</td><td>Reference a <a href="file">File</a> within a file index table.</td></tr><tr><td><a href="table/tableusdget"><strong><code>Table$get</code></strong></a>()</td><td>Fetch table metadata. Once called, the <code>properties</code> field on the table will be fully populated.</td></tr><tr><td><a href="table/tableusdlist_files"><strong><code>Table$list_files</code></strong></a>([max_results, ...])</td><td>Return a list of <a href="file">File</a> instances in a file index table.</td></tr><tr><td><a href="table/tableusdlist_variables"><strong><code>Table$list_variables</code></strong></a>([max_results])</td><td>Return a list of <a href="variable">Variable</a> instances associated with this table.</td></tr><tr><td><a href="table/tableusdto_arrow_batch_reader"><strong><code>Table$to_arrow_batch_reader</code></strong></a>([...])</td><td>Returns a reader that mimics the <a href="https://arrow.apache.org/docs/dev/r/reference/RecordBatchReader.html">Arrow RecordBatchStreamReader</a>, which can then be consumed to process batches of rows in a streaming fashion.</td></tr><tr><td><a href="table/tableusdto_arrow_dataset"><strong><code>Table$to_arrow_dataset</code></strong></a>([max_results, ...])</td><td>Return an <a href="https://arrow.apache.org/docs/r/reference/Dataset.html">Arrow Dataset</a> for the table. Data is backed by disk, allowing for larger-than-memory analysis.</td></tr><tr><td><a href="table/tableusdto_arrow_table"><strong><code>Table$to_arrow_table</code></strong></a>([max_results, ...])</td><td>Return an <a href="https://arrow.apache.org/docs/r/reference/Table-class.html">Arrow Table</a> with the table's data. This is the highest-performance option for loading data in-memory.</td></tr><tr><td><a href="table/tableusdto_data_frame"><strong><code>Table$to_data_frame</code></strong></a>([max_results, ...])</td><td>Return a <a href="https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/data.frame">data.frame</a> with the table's data.</td></tr><tr><td><a href="table/tableusdto_data_table"><strong><code>Table$to_data_table</code></strong></a>([max_results, ...])</td><td>Return a <a href="https://rdatatable.gitlab.io/data.table/">data.table</a> with the table's data.</td></tr><tr><td><a href="table/tableusdto_directory"><strong><code>Table$to_directory</code></strong></a>([max_results, ...])</td><td>Return a virtual <a href="directory">Directory</a> based off a file index table.</td></tr><tr><td><a href="table/tableusdto_read_streams"><strong><code>Table$to_read_streams</code></strong></a>([target_count, ...])</td><td>Return a list of <a href="readstream">ReadStreams</a> for parallel processing.</td></tr><tr><td><a href="table/tableusdto_tibble"><strong><code>Table$to_tibble</code></strong></a>([max_results, variables, ...])</td><td>Return a <a href="https://tibble.tidyverse.org/">tibble</a> with the table's data.</td></tr><tr><td><a href="table/tableusdto_sf_tibble"><strong><code>Table$to_sf_tibble</code></strong></a>([max_results, ...])</td><td>Return a <a href="https://r-spatial.github.io/sf/index.html">simple features tibble</a> with a table's data. Used for tables that contain a geography variable.</td></tr><tr><td><a href="table/tableusdvariable"><strong><code>Table$variable</code></strong></a>(name)</td><td>Reference a <a href="variable">Variable</a> within the table.</td></tr><tr><td></td><td></td></tr><tr><td><strong>Uploading and modifying data</strong></td><td></td></tr><tr><td><a href="table/tableusdadd_files"><strong><code>Table$add_files</code></strong></a>([files, directory])</td><td>Upload non-tabular (unstructured) files to an unreleased file index table. </td></tr><tr><td><a href="table/tableusdcreate"><strong><code>Table$create</code></strong></a>([description, ...])</td><td>Create a table within a dataset if it doesn't already exist. Table must belong to an unreleased version of the dataset.</td></tr><tr><td><a href="table/tableusddelete"><strong><code>Table$delete</code></strong></a>()</td><td>Delete a table belonging to an unreleased version of a dataset.</td></tr><tr><td><a href="table/tableusdlist_uploads"><strong><code>Table$list_uploads</code></strong></a>([max_results])</td><td>Return a list of all uploads on a table.</td></tr><tr><td><a href="table/tableusdupdate"><strong><code>Table$update</code></strong></a>([name, description, ...])</td><td>Update various properties on the table.</td></tr><tr><td><a href="table/tableusdupdate_variables"><strong><code>Table$update_variables</code></strong></a>(variables)</td><td>Bulk update variable metadata on a table.</td></tr><tr><td><a href="table/tableusdupload"><strong><code>Table$upload</code></strong></a>(name)</td><td>Construct a new <a href="upload">upload instance</a>, scoped to this table.</td></tr></tbody></table>
