check_field_class: Check the classes of fields in a GTFS object element

View source: R/checks.R

check_field_classR Documentation

Check the classes of fields in a GTFS object element

Description

Checks the classes of fields, represented by columns, inside a GTFS object element.

Usage

check_field_class(x, file, fields, classes)

assert_field_class(x, file, fields, classes)

Arguments

x

A GTFS object.

file

A string. The element, that represents a GTFS text file, whose fields' classes should be checked.

fields

A character vector. The fields to have their classes checked.

classes

A character vector, with the same length of fields. The classes that each field must inherit from.

Value

check_field_class returns TRUE if the check is successful, and FALSE otherwise.
assert_field_class returns x invisibly if the check is successful, and throws an error otherwise.

See Also

Other checking functions: check_field_exists(), check_file_exists()

Examples

gtfs_path <- system.file("extdata/ggl_gtfs.zip", package = "gtfsio")
gtfs <- import_gtfs(gtfs_path)

check_field_class(
  gtfs,
  "calendar",
  fields = c("monday", "tuesday"),
  classes = rep("integer", 2)
)

check_field_class(
  gtfs,
  "calendar",
  fields = c("monday", "tuesday"),
  classes = c("integer", "character")
)


gtfsio documentation built on Oct. 20, 2023, 9:08 a.m.