R/logbook_distribution_control.R
logbook_distribution_control.Rd
The purpose of the logbook_distribution_control function is to provide a table of data that contains an inconsistency between the small and large sample weights and the sum of the small and big weights of the associated well
data.frame expected. Csv or output of the function data_extraction, which must be done before using the logbook_distribution_control () function.
data.frame expected. Csv or output of the function data_extraction, which must be done before using the logbook_distribution_control () function.
data.frame expected. Csv or output of the function data_extraction, which must be done before using the logbook_distribution_control () function.
data.frame expected. Csv or output of the function data_extraction, which must be done before using the logbook_distribution_control () function.
character expected. Kind of expected output. You can choose between "message", "report" or "logical".
character expected. Default values: c("ALB", "YFT", "BET", "SKJ"). List of the inventory of species (FAO code) used to calculate weight category small and big in well
character expected. Default values: c("SKJ"). Vector of species categorized as small if weight category information is missing
character expected. Default values: c("W-1"). Vector of small weight category codes
character expected. Default values: c("W-2"). Vector of big weight category codes
character expected. Default values: c("W-9"). Vector of unknown weight category codes
The function returns a character with output is "message", a data.frame with output is "report", a logical with output is "logical"
The input dataframe must contain all these columns for the function to work :
sample_id
sample_well
trip_id
sample_smallsweight
sample_bigsweight
well_id
well_label
trip_id
wellactivity_id
well_id
wellactivityspecies_id
wellactivity_id
weightcategory_code
species_fao_code
wellactivityspecies_weight
#Sample 1 and 2 are ok,
#Sample 3 has not small weight in well,
#Sample 4 has not bigs weight in sample,
#Sample 5 has different bigs weight,
#Sample 6 and 7 has different small weight
dataframe1 <- data.frame(sample_id = c("1", "2", "3", "4", "5", "6", "7"),
sample_well = c("well_1", "well_2", "well_3", "well_4", "well_5",
"well_6","well_7"),
trip_id = c("1", "1", "1", "1", "1", "1", "1"),
sample_smallsweight = c(6, 25, 14, 0, NA, 10, 8),
sample_bigsweight = c(12, 0, 9, NA, 6, 0, 0))
dataframe2 <- data.frame(well_id = c("1", "2", "3", "4", "5", "6", "7"),
well_label = c("well_1", "well_2", "well_3", "well_4", "well_5", "well_6",
"well_7"),
trip_id = c("1", "1", "1", "1", "1", "1", "1"))
dataframe3 <- data.frame(wellactivity_id = c("1", "2", "3", "4", "5", "6", "7", "8"),
well_id = c("1", "1", "2", "3", "4", "5", "6", "7"))
dataframe4 <- data.frame(wellactivityspecies_id = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
"10", "11", "12", "13", "14"),
wellactivity_id = c("1", "1", "1", "2", "3", "4", "4", "5", "6", "7",
"7", "7", "8", "8"),
weightcategory_code = c("W-1", "W-9", "W-2", "W-2", "W-1", "W-2", "W-9",
"W-2", "W-2", "W-1", "W-9", "W-9", "W-1", "W-1"),
species_fao_code = c("BET", "SKJ", "SKJ", "ALB", "SKJ", "BET", "BET",
"ALB", "SKJ", "SKJ", "SKJ", "BET", "ALB", "JOS"),
wellactivityspecies_weight = c(4, 2, 7, 5, 25, 9, 14, 5, 17, 10, 5, 2, 7,
1))
logbook_distribution_control(dataframe1, dataframe2, dataframe3, dataframe4, output = "report")
#> sample_id logical sample_smallsweight sample_bigsweight sample_well
#> 1 1 TRUE 6 12 well_1
#> 2 2 TRUE 25 0 well_2
#> 3 3 FALSE 14 9 well_3
#> 4 4 FALSE 0 NA well_4
#> 5 5 FALSE NA 6 well_5
#> 6 6 FALSE 10 0 well_6
#> 7 7 FALSE 8 0 well_7
#> weight_sum_small_filter weight_sum_big_filter weight_sum_small weight_sum_big
#> 1 6 12 6 12
#> 2 25 NaN 25 NaN
#> 3 NaN 9 14 9
#> 4 NaN 5 NaN 5
#> 5 NaN 17 NaN 17
#> 6 15 NaN 17 NaN
#> 7 7 NaN 8 NaN