Returns the Table Schema of a Data Resource (in a Data Package), i.e. the
content of its schema
property, describing the resource's fields, data
types, relationships, and missing values.
The resource must be a Tabular Data Resource.
Arguments
- package
Data Package object, as returned by
read_package()
orcreate_package()
.- resource_name
Name of the Data Resource.
Details
See vignette("table-schema")
to learn more about Table Schema.
Examples
# Load the example Data Package
package <- example_package()
# Get the Table Schema for the resource "observations"
schema <- get_schema(package, "observations")
str(schema)
#> List of 4
#> $ fields :List of 7
#> ..$ :List of 3
#> .. ..$ name : chr "observation_id"
#> .. ..$ type : chr "string"
#> .. ..$ constraints:List of 2
#> .. .. ..$ required: logi TRUE
#> .. .. ..$ unique : logi TRUE
#> ..$ :List of 3
#> .. ..$ name : chr "deployment_id"
#> .. ..$ type : chr "string"
#> .. ..$ constraints:List of 1
#> .. .. ..$ required: logi TRUE
#> ..$ :List of 4
#> .. ..$ name : chr "timestamp"
#> .. ..$ type : chr "datetime"
#> .. ..$ format : chr "%Y-%m-%dT%H:%M:%S%z"
#> .. ..$ constraints:List of 1
#> .. .. ..$ required: logi TRUE
#> ..$ :List of 3
#> .. ..$ name : chr "scientific_name"
#> .. ..$ type : chr "string"
#> .. ..$ constraints:List of 1
#> .. .. ..$ required: logi FALSE
#> ..$ :List of 3
#> .. ..$ name : chr "count"
#> .. ..$ type : chr "integer"
#> .. ..$ constraints:List of 2
#> .. .. ..$ required: logi FALSE
#> .. .. ..$ minimum : int 1
#> ..$ :List of 3
#> .. ..$ name : chr "life_stage"
#> .. ..$ type : chr "string"
#> .. ..$ constraints:List of 2
#> .. .. ..$ required: logi FALSE
#> .. .. ..$ enum : chr [1:5] "adult" "subadult" "juvenile" "offspring" ...
#> ..$ :List of 3
#> .. ..$ name : chr "comments"
#> .. ..$ type : chr "string"
#> .. ..$ constraints:List of 1
#> .. .. ..$ required: logi FALSE
#> $ missingValues: chr [1:3] "" "NA" "NaN"
#> $ primaryKey : chr "observation_id"
#> $ foreignKeys :List of 1
#> ..$ :List of 2
#> .. ..$ fields : chr "deployment_id"
#> .. ..$ reference:List of 2
#> .. .. ..$ resource: chr "deployments"
#> .. .. ..$ fields : chr "deployment_id"