Functions to import taxonomy data into MareFrame DB

mfdb_import_area(mdb, data_in)
    mfdb_import_division(mdb, data_in)
    mfdb_import_sampling_type(mdb, data_in)
    mfdb_import_bait_type_taxonomy(mdb, data_in)
    mfdb_import_population_taxonomy(mdb, data_in)
    mfdb_import_port_taxonomy(mdb, data_in)
    mfdb_import_tow_taxonomy(mdb,  data_in)
    mfdb_import_net_type_taxonomy(mdb, data_in)
    mfdb_import_trip_taxonomy(mdb, data_in)
    mfdb_import_vessel_taxonomy(mdb,  data_in)
    mfdb_import_vessel_owner_taxonomy(mdb,  data_in)

    mfdb_empty_taxonomy(mdb, taxonomy_name)

    mfdb_import_cs_taxonomy(mdb, taxonomy_name, data_in)

Arguments

mdb

Database connection created by mfdb().

taxonomy_name

The name of the taxonomy to import, if there isn't a special function for it. See mfdb:::mfdb_taxonomy_tables for possible values.

data_in

A data.frame of data to import, see details.

Details

MFDB taxonomies define the values you can use when importing / querying for data. They need to be populated with the values you need before data is imported. Most taxonomies are pre-populated by the MFDB package, so you should use the predefined values. Others however this does not make sense, so should be done separately. This is what these functions do.

mfdb_import_division is a special case, which imports groupings of areacells into divisions, if you haven't already done this with mfdb_import_area or your divisions are too complicated to represent this way. The data_in should be a list of areacell vectors, with division names. For example, list(divA = c('45G01', '45G02', '45G03'))

Beyond this, all functions accept the following columns:

id

Optional. A numeric ID to use internally, defaults to 1..n

name

Required. A vector of short names to use in data, e.g. "SEA"

t_group

Optional. A vector of the that groups together a set of values

Note that the database doesn't use your short names internally. This means you can rename items by changing what name is set to. t_group allows taxonomy values to be grouped together. For example, giving all vessels in a fleet the same t_group you can then query the entire fleet as well as individually.

mfdb_import_area imports areacell information for your case study. Beyond the above, you can also provide the following:

size

The size of the areacell

depth

The depth of the areacell

division

The name of the division this areacell is part of

mfdb_import_vessel_taxonomy imports names of vessels into the taxonomy table, so they can be used when importing samples. As well as the above, you can also specify:

full_name

Optional. The full name of this vessel

length

Optional. The length of the vessel in meters

power

Optional. The vessel's engine power in KW

tonnage

Optional. The vessel's gross tonnage

vessel_owner

Optional. The short name of the vessel owner (see mfdb_import_vessel_owner_taxonomy)

mfdb_import_vessel_owner_taxonomy imports names of vessels owners into a taxonomy table, to be used when importing vessels. As well as name/t_group, you can also specify:

full_name

Optional. The full name of the owning organisation

mfdb_import_tow_taxonomy imports names of vessels into the taxonomy table, so they can be used when importing samples. As well as the above, you can also specify:

latitude

Optional.

longitude

Optional.

depth

Optional. Depth in meters

length

Optional. Length in meters

mfdb_import_port_taxonomy imports names of ports that trips can start/finish at. As well as id/name, you can provide:

latitude

Optional. Latitutde as real number

longitude

Optional. Latitutde as real number

institute

Optional. Institute (from institute taxonomy, could be country) responsible for port

mfdb_import_trip_taxonomy imports names of trips that samples can be labelled part of. As well as id/name, you can provide:

latitude

Optional. Latitutde as real number

longitude

Optional. Latitutde as real number

start_date

Optional. Start date-time, as YYYY-MM-DD or YYYY-MM-DD HH:MM:SS

end_date

Optional. End date-time, as YYYY-MM-DD or YYYY-MM-DD HH:MM:SS

crew

Optional. Number of crew on-board

oil_consumption

Optional. Total oil consumption for trip

start_port

Optional. Name of port (from port taxonomy) trip started

end_port

Optional. Name of port (from port taxonomy) trip finished

mfdb_import_sampling_type imports sampling types so that you can then use these against records in the sample table. You can also provide:

description

Optional. A vector of descriptive names, e.g. "sea sampling"

mfdb_empty_taxonomy allows you to empty out a taxonomy of previous data. The import functions insert or update values that already exist, based on the numeric ID for these values. They do not delete anything, as it may be impossible to remove rows without destroying existing data.

However, if e.g. you want to replace the species taxonomy with an entirely different one you will need to flush it first, before you import any data. Use this function, then mfdb_import_species_taxonomy to import the new taxonomy.

NB: This won't be possible if there is some data already using any of the terms. It is best used before your database is populated.

Value

NULL