pkgdown/analytics.html

Skip to contents

Add a standard GeoLocator-DP resource to a package. This essentially wraps frictionless::add_resource() but with prepartions steps of the data:

  • extending the schema with extra columns present in data when allowed by fieldsMatch;

  • adding missing schema columns to data with typed NA values when needed;

  • reordering data columns to match the schema, because frictionless::add_resource() expects fields in schema order.

  • casting columns to schema types when cast_type = TRUE, for example converting strings to dates, numbers, or integers when required by the schema, so the stored resource is consistent with the declared schema.

For common package resources, the resource accessors are usually a more convenient user-facing interface.

Usage

add_gldp_resource(
  pkg,
  resource_name,
  data,
  cast_type = FALSE,
  replace = FALSE,
  delim = ","
)

Arguments

pkg

A GeoLocator Data Package object to which the resource will be added.

resource_name

A character string specifying the name of the resource. This name is used to locate the schema file.

data

A data frame containing the data to be added as a resource. The data frame will be adjusted according to the schema.

cast_type

A logical value indicating whether the data frame should be cast to the types specified in the schema. Defaults to FALSE.

replace

If TRUE, the added resource will replace an existing resource with the same name.

delim

Single character used to separate the fields in the CSV file(s), e.g. \t for tab delimited file. Will be set as delimiter in the resource Table Dialect, so read functions . know how to read the file(s).

Value

The updated GeoLocator Data Package object with the new resource added.

See also

tags(), observations(), and the other resource accessors for the usual user-facing way to modify standard GeoLocator-DP resources.