mfdb_import: MareFrame Import functions

Description Usage Arguments Details Examples

Description

Functions to import data into MareFrame DB

Usage

1
2
3
4
5
    mfdb_import_survey(mdb, data_in, ...)
    mfdb_import_area(mdb, data_in)
    mfdb_import_division(mdb, data_in)
    mfdb_import_temperature(mdb, data_in)
    mfdb_import_sampling_type(mdb, data_in)

Arguments

mdb

Database connection created by mfdb().

data_in

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

...

Metadata about the survey data, see details.

Details

For mfdb_import_survey, the metadata can contain:

data_source

A name for this data, e.g. it's filename. Used so you can replace it later without disturbing other data

institute

Optional. An institute name, see mfdb::institute for possible values

gear

Optional. Gear name, see mfdb::gear for possible values

vessel

Optional. Vessel name, see mfdb::vessel for possible values

sampling_type

Optional. A sampling_type, see mfdb::sampling_type for possible values

And data_in should be a data.frame with the following columns:

year

Required. Year each sample was taken, e.g. c(2000,2001)

month

Required. Month (1–12) each sample was taken, e.g. c(1,12)

areacell

Required. Areacell sample was taken within

species

Optional, default c(NA). Species of sample, see mfdb::species for possible values

age

Optional, default c(NA). Age of sample, or mean age

sex

Optional, default c(NA). Sex of sample, see mfdb::sex for possible values

length

Optional, default c(NA). Length of sample / mean length of all samples

length_var

Optional, default c(NA). Sample variance, if data is already aggregated

length_min

Optional, default c(NA). Minimum theoretical length, if data is already aggregated

weight

Optional, default c(NA). Weight of sample / mean weight of all samples

weight_var

Optional, default c(NA). Sample variance, if data is already aggregated

count

Optional, default c(1). Number of samples this row represents (i.e. if the data is aggregated)

mfdb_import_area imports areacell information for your case study. The data_in should be a data.frame with the following columns:

id

A numeric ID for this areacell (will be combined with the case study number internally)

name

The name of the areacell, e.g. '45G01'

size

The size of the areacell

mfdb_import_division imports groupings of areacells into divisions. The data_in should be a list of areacell vectors, with division names. For example, list(divA = c('45G01', '45G02', '45G03'))

mfdb_import_temperature imports temperature time-series data for areacells. The data_in should be a data.frame with the following columns:

id

A numeric ID for this areacell (will be combined with the case study number internally)

year

Required. Year each sample was taken, e.g. c(2000,2001)

month

Required. Month (1–12) each sample was taken, e.g. c(1,12)

areacell

Required. Areacell sample was taken within

temperature

The temperature at given location/time

mfdb_import_sampling_type imports names of sampling types for this case study. The data_in should be a data.frame with the following columns:

id

A numeric ID for this sampling type

name

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

description

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
# data/cod-1998.csv contains:-
# year,month,areacell,species,age,sex,length
# 1998,1,35F1,COD,3,M,140
# 1998,1,35F1,COD,3,M,150
# 1998,1,35F1,COD,3,F,150

mfdb_import_survey(mdb,
    data_source = 'cod-1998',
    case_study = 'Iceland',
    institute = 'MRI',
    gear = 'GIL',
    vessel = '2.RSH',
    sampling_type = 'HAR',
    read.csv("data/cod-1998.csv"))

## End(Not run)

sCervino/mfdb documentation built on May 18, 2019, 1:31 p.m.