R/logbook_weighting_control.R
    logbook_weighting_control.RdThe purpose of the logbook_weighting_control function is to provide a table of data that contains an inconsistency between the sample weighting
data.frame expected. Csv or output of the function data_extraction, which must be done before using the logbook_weighting_control () function.
data.frame expected. Csv or output of the function data_extraction, which must be done before using the logbook_weighting_control () function.
data.frame expected. Csv or output of the function data_extraction, which must be done before using the logbook_weighting_control () function.
data.frame expected. Csv or output of the function data_extraction, which must be done before using the logbook_weighting_control () function.
character expected. Kind of expected output. You can choose between "message", "report" or "logical".
character expected. Default values: c("6", "2"). List of two elements, the first is the seine vessel type code, and the second is the baitboat type code.
numeric expected. Default values: 100. Seiner threshold weight
numeric expected. Default values: 0.95. Percentage threshold between weight and weighted weight for seiners
character expected. Default values: c("11"). List of sample type codes for baitboat fresh landings
character expected. Default values: c("L-YFT-10", "L-BET-10", "L-TUN-10"). List of codes for fresh baitboat landings
numeric expected. Default values: 1. Threshold for baitboats with respect to the difference between the weighted weight and the landed fresh weight and the difference between the weight and the weighted weight
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_smallsweight
  sample_bigsweight
  sample_totalweight
  trip_id
  sampletype_code
  sampleactivity_id
  sampleactivity_weightedweight
  sample_id
  trip_id
  vesseltype_code
  vesseltype_label1
  landing_id
  landing_weight
  weightcategory_code
  trip_id
#Sample 1, 3, 4, 7, 9, 12, 17 and 18 are ok,
#Sample 2 has a weighted weight ratio over the sum of the weights of small and big individuals below
#         the threshold (threshold_ratio),
#Sample 5 has a difference between fresh landing and weighted weight above the
#         threshold (threshold_baitboat),
#Sample 6 has no vessel type,
#Sample 8 has no sample type,
#Sample 10 has no sample activity,
#Sample 11 has a difference between total weight and weighted weight above the
#          threshold (threshold_baitboat),
#Sample 13 has no sample activity,
#Sample 14 has a difference between sum of the weights of small and big individuals and weighted
#          weight above the threshold (threshold_baitboat),
#Sample 15 has the sum of the weights of small and big individuals above the
#          threshold (threshold_weight),
#Sample 16 has the sum of the total weight above the threshold (threshold_weight),
#Sample 19 has a weighted weight ratio over the total weight below the threshold (threshold_ratio)
dataframe1 <- data.frame(sample_id = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
                                       "12", "13", "14", "15", "16", "17", "18", "19"),
                         sample_smallsweight = c(10, 32, 2.5, 30, 12, 7, NA, 6, NA, 4, 8, 3, 7, 13,
                                                 54, 3, 8, 2, 16),
                         sample_bigsweight = c(50, 2, 9, 3, 6, 13, 0, 3, 7, 2, 0, 2, 8, 3, 62, 8,
                                               15, 6, 1),
                         sample_totalweight = c(NA, NA, NA, 33, 8, 9, 142, 2, 14, 10, 3, 0, NA, 0,
                                                0, 104, 24, 36, 12),
                         trip_id =  c("1", "1", "2", "3", "4", "5", "6", "7", "8", "8", "8", "8",
                                      "8", "8", "1", "1", "1", "1", "1"),
                         sampletype_code = c("1", "1", "1", "11", "11", "1", "1", NA, "1", "1", "1",
                                             "1", "1", "1", "1", NA, NA, NA, NA))
dataframe2 <- data.frame(sampleactivity_id = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
                                              "11", "12", "13", "14", "15", "16", "17"),
                         sampleactivity_weightedweight = c(70, 5, 18, 12, 33, 5, 9, 4, 13, 7, 4, 15,
                                                           116, 104, 24, 35, 11),
                         sample_id = c("1", "1", "2", "3", "4", "5", "6", "8", "9", "11", "12",
                                       "14", "15", "16", "17", "18", "19"))
dataframe3 <- data.frame(trip_id = c("1", "2", "3", "4", "6", "7", "8"),
                         vesseltype_code = c("6", "6", "2", "2", "3", "2", "2"),
                         vesseltype_label = c("vessel_type_1", "vessel_type_1", "vessel_type_2",
                                              "vessel_type_2", "vessel_type_3", "vessel_type_2",
                                              "vessel_type_2"))
dataframe4 <- data.frame(landing_id = c("1", "2", "3", "4", "5", "6"),
                         landing_weight = c(85, 26, 30, 2.6, 20, 3),
                         weightcategory_code = c("W-1", "W-1", "L-YFT-10", "L-YFT-10", "L-YFT-10",
                                                 "L-BET-10"),
                         trip_id = c("1", "2", "3", "3", "4", "7"))
logbook_weighting_control(dataframe1, dataframe2, dataframe3, dataframe4, output = "report")
#>    sample_id logical sample_smallsweight sample_bigsweight sample_totalweight
#> 1          1    TRUE                10.0                50                 NA
#> 2          2   FALSE                32.0                 2                 NA
#> 3          3    TRUE                 2.5                 9                 NA
#> 4          4    TRUE                30.0                 3                 33
#> 5          5   FALSE                12.0                 6                  8
#> 6          6   FALSE                 7.0                13                  9
#> 7          7    TRUE                  NA                 0                142
#> 8          8   FALSE                 6.0                 3                  2
#> 9          9    TRUE                  NA                 7                 14
#> 10        10   FALSE                 4.0                 2                 10
#> 11        11   FALSE                 8.0                 0                  3
#> 12        12    TRUE                 3.0                 2                  0
#> 13        13   FALSE                 7.0                 8                 NA
#> 14        14    TRUE                13.0                 3                  0
#> 15        15   FALSE                54.0                62                  0
#> 16        16   FALSE                 3.0                 8                104
#> 17        17    TRUE                 8.0                15                 24
#> 18        18    TRUE                 2.0                 6                 36
#> 19        19   FALSE                16.0                 1                 12
#>    sampletype_code weightedweight vesseltype_label sum_landing_weight_baitboat
#> 1                1             75    vessel_type_1                          NA
#> 2                1             18    vessel_type_1                          NA
#> 3                1             12    vessel_type_1                          NA
#> 4               11             33    vessel_type_2                        32.6
#> 5               11              5    vessel_type_2                        20.0
#> 6                1              9             <NA>                          NA
#> 7                1             NA    vessel_type_3                          NA
#> 8             <NA>              4    vessel_type_2                         3.0
#> 9                1             13    vessel_type_2                          NA
#> 10               1             NA    vessel_type_2                          NA
#> 11               1              7    vessel_type_2                          NA
#> 12               1              4    vessel_type_2                          NA
#> 13               1             NA    vessel_type_2                          NA
#> 14               1             15    vessel_type_2                          NA
#> 15               1            116    vessel_type_1                          NA
#> 16            <NA>            104    vessel_type_1                          NA
#> 17            <NA>             24    vessel_type_1                          NA
#> 18            <NA>             35    vessel_type_1                          NA
#> 19            <NA>             11    vessel_type_1                          NA