Table: Table Class

TableR Documentation

Table Class

Description

Table class for working with tabular data and associated schema. A table is created from a data source and optionally a schema. It provides methods for iteration, reading, inference, validation, and saving of tabular data.

Usage

# Table$load(source, schema = NULL, strict = FALSE, headers = 1, ...)

Arguments

source

Data source. Can be one of:

String

Path to a local CSV file or a URL to a remote CSV file.

List of lists

Each sublist represents a row.

Connection

A readable stream with CSV content.

Function

Function returning a readable stream.

schema

Optional. Schema object or schema descriptor as JSON, list, or URL.

strict

Logical. If TRUE, validation errors raise immediately. If FALSE, errors are stored in $errors.

headers

Data source headers. Can be:

Integer

Row number containing the headers.

List

Vector of header names if the data does not contain a header row.

...

Additional options passed to the CSV parser. See CSV Parser Options. By default, ltrim is TRUE according to the CSV Dialect spec.

Format

R6Class object.

Value

Object of class R6Class.

Methods

Table$new(source, schema, strict, headers)

Use Table$load to instantiate a Table object.

iter(keyed, extended, cast = TRUE, relations = FALSE, stream = FALSE)

Iterates over table rows.

keyed

Logical. Whether to return rows as named lists.

extended

Logical. Whether to include row metadata.

cast

Logical. Whether to cast data to schema types.

relations

List of foreign key references (named list of resource names with reference rows).

stream

Logical. Return an R stream if TRUE.

read(keyed, extended, cast = TRUE, relations = FALSE, limit)

Reads and returns the entire table as rows.

keyed

Logical. Whether to return keyed rows.

extended

Logical. Whether to include row metadata.

cast

Logical. Whether to cast values.

relations

List of foreign key references (see iter).

limit

Integer. Maximum number of rows to return.

infer(limit = 100)

Infers the schema from the data.

limit

Integer. Number of rows to use for inference.

save(target)

Saves the table as a CSV file.

target

File path to save to.

Properties

headers

Returns headers detected or provided.

schema

Returns the associated Schema instance.

Details

A table is a fundamental concept in tabular data management. It represents rows and columns of structured data, often accompanied by a schema (metadata describing field types, constraints, etc.).

The physical representation of a table refers to the raw data (e.g., in CSV or JSON form). The logical representation corresponds to the parsed and typed values conforming to schema definitions.

This class supports both representations, applying validation, constraint checking, and conversion between them.

Internally, the package uses:

  • jsonlite for JSON parsing to and from R lists.

  • future for asynchronous loading (e.g., future::value(future_obj)).

See the examples in function documentation for how to use these features with 'tableschema.r'.

Language

The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this documentation are interpreted as described in RFC 2119.

See Also

Table$load, Table Schema Specifications


frictionlessdata/tableschema-r documentation built on April 13, 2025, 3:51 p.m.