Skip to contents

Reads data from a file path (either csv of json file), and optionally from another csv file (with camera data).

Usage

read_data(
  path_rec,
  sep_rec,
  path_cam = NULL,
  sep_cam = NULL,
  NA_strings = c("NA", ""),
  add_rowid = FALSE
)

Arguments

path_rec

A valid file path for records.

sep_rec

separator used for the records.

path_cam

A valid file path for cameras (defaults to NULL).

sep_cam

separator used for the cameras (defaults to NULL).

NA_strings

Vector of characters that should be considered NA after import

add_rowid

Should row IDs be added to the observations df? If yes, row names in the form of "ID_xx" are added to the the dataframe.

Value

A list with one component or a datapackage object.

  • if path_rec is a json file, returns a datapackage object (inheriting list). The data is in the $data slot, which is a list with 2 components:

    • $deployments (cameras)

    • $observations (records)

  • if path_rec is a csv file, returns a list with one component named $data, which is a list with 2 components:

    • $deployments (cameras: if no camera file was provided in path_cam, it is NULL)

    • $observations (records)

Examples

if (FALSE) {
# Read only records
read_data(path_rec = "records.csv", sep_rec = ",")
# Read records and cameras
read_data(path_rec = "records.csv", sep_rec = ",",
          path_cam = "cameras.csv", sep_cam = ",")
# Read a json file
read_data(path_rec = "datapackage.json")
}