| Schema | R Documentation |
A model of a Table Schema with helpful methods for working with the schema and supported data.
Schema instances can be initialized using a schema source, either as a URL to a JSON file or as a JSON object.
The schema is validated upon initialization (see validate).
By default, validation errors are stored in $errors, but in strict mode, they are raised immediately.
# Schema$load(descriptor, strict = FALSE)
descriptor |
A schema descriptor; can be a JSON string, URL, or local file. |
strict |
Logical flag. If |
R6Class object.
Object of class R6Class.
Schema$new(descriptor = descriptor, strict = strict)Use Schema$load to instantiate a Schema class.
getField(name)Returns a schema field by name.
nameString. Name of the schema field.
A Field instance if found, or NULL.
addField(descriptor)Adds a new field to the schema.
descriptorA list representing the field descriptor.
TableSchemaError if the field is invalid.
The added Field instance, or NULL if unsuccessful.
removeField(name)Removes a field by name from the schema.
nameName of the field to remove.
TableSchemaError if removal causes invalid schema.
The removed Field instance, or NULL.
castRow(row)Casts a row of values based on field types and formats.
rowA list representing a data row.
The cast row as a list of typed values.
infer(rows, headers = 1)Infers schema from given data.
rowsA list of lists representing data rows.
headersEither a row number (index) of headers or a list of header names.
A schema descriptor as an object.
commit(strict)Finalizes schema updates.
strictLogical. Whether to enable strict validation mode.
TableSchemaError on failure.
TRUE on success; FALSE if not modified.
save(target)Saves schema descriptor to a file.
targetFile path to save the schema.
TableSchemaError on failure.
TRUE on success.
validReturns TRUE if schema is valid. Always TRUE in strict mode.
errorsReturns list of validation errors. Empty in strict mode.
descriptorReturns the full schema descriptor as a list.
primaryKeyReturns a vector of field names that compose the primary key.
foreignKeysReturns a list of foreign key definitions.
fieldsReturns list of Field instances.
fieldNamesReturns vector of field names.
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.
Schema$load,
Table Schema Specifications
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.