Create the variable_mapping table
create_variable_mapping(
observation,
observation_ancillary = NULL,
location_ancillary = NULL,
taxon_ancillary = NULL
)
(tbl_df, tbl, data.frame) The observation table.
(tbl_df, tbl, data.frame) The optional observation_ancillary table.
(tbl_df, tbl, data.frame) The optional location_ancillary table.
(tbl_df, tbl, data.frame) The optional taxon_ancillary table.
(tbl_df, tbl, data.frame) The variable_mapping table.
This function collects specified data tables, extracts unique variable_name values from each, converts into long (attribute-value) form with the table name and variable_name values to the resulting table's "table_name" and "variable_name" columns, respectively. The resulting table's "mapped_system", "mapped_id", and "mapped_label" are filled with NA
and are to be manually filled.
flat <- ants_L0_flat
# Create inputs to variable_mapping()
observation <- create_observation(
L0_flat = flat,
observation_id = "observation_id",
event_id = "event_id",
package_id = "package_id",
location_id = "location_id",
datetime = "datetime",
taxon_id = "taxon_id",
variable_name = "variable_name",
value = "value",
unit = "unit")
observation_ancillary <- create_observation_ancillary(
L0_flat = flat,
observation_id = "observation_id",
variable_name = c("trap.type", "trap.num", "moose.cage"))
location_ancillary <- create_location_ancillary(
L0_flat = flat,
location_id = "location_id",
variable_name = "treatment")
taxon_ancillary <- create_taxon_ancillary(
L0_flat = flat,
taxon_id = "taxon_id",
variable_name = c(
"subfamily", "hl", "rel", "rll", "colony.size",
"feeding.preference", "nest.substrate", "primary.habitat",
"secondary.habitat", "seed.disperser", "slavemaker.sp",
"behavior", "biogeographic.affinity", "source"),
unit = c("unit_hl", "unit_rel", "unit_rll"))
# Create variable_mapping table
variable_mapping <- create_variable_mapping(
observation = observation,
observation_ancillary = observation_ancillary,
location_ancillary = location_ancillary,
taxon_ancillary = taxon_ancillary)
variable_mapping
#> # A tibble: 19 x 6
#> variable_mapping_id table_name variable_name mapped_system mapped_id
#> <chr> <chr> <chr> <chr> <chr>
#> 1 1 observation abundance NA NA
#> 2 2 observation_ancill~ trap.type NA NA
#> 3 3 observation_ancill~ trap.num NA NA
#> 4 4 observation_ancill~ moose.cage NA NA
#> 5 5 location_ancillary treatment NA NA
#> 6 6 taxon_ancillary subfamily NA NA
#> 7 7 taxon_ancillary hl NA NA
#> 8 8 taxon_ancillary rel NA NA
#> 9 9 taxon_ancillary rll NA NA
#> 10 10 taxon_ancillary colony.size NA NA
#> 11 11 taxon_ancillary feeding.pref~ NA NA
#> 12 12 taxon_ancillary nest.substra~ NA NA
#> 13 13 taxon_ancillary primary.habi~ NA NA
#> 14 14 taxon_ancillary secondary.ha~ NA NA
#> 15 15 taxon_ancillary seed.dispers~ NA NA
#> 16 16 taxon_ancillary slavemaker.sp NA NA
#> 17 17 taxon_ancillary behavior NA NA
#> 18 18 taxon_ancillary biogeographi~ NA NA
#> 19 19 taxon_ancillary source NA NA
#> # ... with 1 more variable: mapped_label <chr>