Skip to contents

Check location data

Usage

check_locations(location_map)

Arguments

locations

a data.frame, with integer columns id and parent_id. See Details for restrictions.

Value

a data.table, with the canonical location structure, and a layer column

Details

imuGAP() works on a hierarchical model of locations, so needs to be told what that structure is. This method checks that the location structure is valid, and returns a canonical version including the layer size.

id may not have an duplicates. If there is a row with id == 1, it must have parent_id == NA. max(id) must equal the number of rows, give or take the presence of the root id == 1 - put another way, id must be seq_len(dim(locations)[1]) (again, give or take 1 for the root node). After ordering, id and parent_id must be all(diff(id) == 1) and all(diff(parent_id) %in% c(0, 1)).

Intended future capability: be able to extract a location structure that satisfies the requirements. In particular:

  • allow a root other than 1; would be defined by a parent_id == NA

  • accept arbitrary column types for id, including a non-covering set of integers, and parent_id; the return object will include an appropriate remapping to be applied to weighting data

  • accept arbitrary layer depths