resource: Get or overwrite a Data Resource

View source: R/resource.R

resourceR Documentation

Get or overwrite a Data Resource

Description

Gets or overwrites a Data Resource from/in a Data Package. These functions are designed for internal use in other packages. For public manipulation of resources, use add_resource() and remove_resource().

resource() gets a Data Resource from a Data Package by its name. The returned value will be a list describing a Data Resource, with a new attribute data_location to indicate how the data are attached. If present, path will be updated to the full path(s).

⁠resource<-⁠ overwrites a Data Resource in Data Package with a new value. The assigned value will typically be a resource obtained with resource() and then manipulated. The assignment function will therefore revert internal changes made by resource() (i.e. removing the attribute data_location and updating paths to the original values). The assigned value is otherwise not validated, so use with care.

Usage

resource(package, resource_name)

resource(package, resource_name) <- value

Arguments

package

Data Package object, as returned by read_package() or create_package().

resource_name

Name of the Data Resource.

value

Value to assign.

Details

See vignette("data-resource") to learn more about Data Resource.

Value

List describing a Data Resource.

package with overwritten resource.

See Also

Other accessor functions: resource_names(), schema()

Examples

# Load the example Data Package
package <- example_package()

# Get the resource "deployments"
resource <- resource(package, "deployments")
str(resource)

# Update the resource
resource$description <- "Table with deployments."

# Overwrite the resource
resource(package, "deployments") <- resource

# Updating a resource property can also be done in one step
resource(package, "deployments")$description <- "Table with deployments."

frictionless documentation built on July 31, 2026, 9:06 a.m.