Description Usage Arguments Details Value Examples
Aggregate data from the database in a variety of ways
1 2 3 4 5 6 7 | mfdb_area_size(mdb, params)
mfdb_temperature(mdb, params)
mfdb_sample_count(mdb, cols, params)
mfdb_sample_meanlength(mdb, cols, params)
mfdb_sample_meanlength_stddev(mdb, cols, params)
mfdb_sample_meanweight(mdb, cols, params)
mfdb_sample_meanweight_stddev(mdb, cols, params)
|
mdb |
An object created by |
cols |
Any additonal columns to group by, see details. |
params |
A list of parameters, see details. |
The items in the params
list either restrict data that is returned, or
groups data if they are also in the cols
vector, or are 'year',
'timestep', or 'area'.
If you are grouping by the column, params
should contain one of the
following:
Don't do any grouping, instead put 'any' in the resulting column.
For example, age = NULL
results in "any".
Aggregate all samples together where they match.
For example, year = 1990:2000
results in 1990, ... , 2000.
Don't do any aggregation for this column, return all possible values.
Group several discrete items together.
For example, age = mfdb_group(young = 1:3, old = 4:5)
results in "young" and "old".
Group irregular ranges together.
For example, length = mfdb_interval('len', c(0, 10, 100, 1000))
results in "len0", "len10", "len100", and "len1000".
Group regular ranges together.
For example, length = mfdb_step_interval('len', to = 100, by = 10)
results in "len0", "len10", ... , "len100".
In addition, params
can contain other arguments to purely restrict the
data that is returned.
A vector of institute names, see mfdb::institute for possible values
A vector of gear names, see mfdb::gear for possible values
A vector of vessel names, see mfdb::vessel for possible values
A vector of sampling_type names, see mfdb::sampling_type for possible values
A vector of species names, see mfdb::species for possible values
A vector of sex names, see mfdb::sex for possible values
To save specifying the same items repeatedly, you can use list concatenation to keep some defaults, for example:
1 2 | defaults <- list(year = 1998:2000)
mfdb_sample_meanlength(mdb, c('age'), c(list(), defaults))
|
All will return a list of data.frame objects. Precisely what columns these will contain depends on the function called.
Returns year, step, area, (mean) temperature
Returns year,step,area,(group cols),number (of samples)
Returns year,step,area,(group cols),number (of samples),mean (length in group)
As mfdb_sample_meanlength, but also returns std. deviation.
Returns year,step,area,(group cols),number (of samples),mean (weight of group)
As mfdb_sample_meanweight, but also returns std. deviation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
agg_data <- mfdb_sample_count(mdb, c('age', 'length'),
params = c(list(
year = c(1990, 1991),
length = mfdb_interval("len", seq(0, 500, by = 30)),
age = mfdb_group('young' = c(1,2,3)),
null = NULL), opt_catch))
gadget_dir_write(gd, gadget_likelihood_component("catchdistribution",
name = "cdist",
weight = 0.9,
data = agg_data[[1]],
area = attr(agg_data[[1]], "area"),
age = attr(agg_data[[1]], "age")))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.