/
checks.R
1036 lines (985 loc) · 45.2 KB
/
checks.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#' @name check_trip_id
#' @title Attribute "trip_id" verification
#' @param trip_id Object of class {\link[base]{character}} expected. Trip identification.
#' @description Check if the item "trip_id" have one unique class identified as character.
check_trip_id <- function(trip_id) {
if (length(x = class(x = trip_id)) != 1
|| ! inherits(x = trip_id,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"trip_id\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_wellplan_id
#' @title Attribute "wellplan_id" verification
#' @param wellplan_id Object of class {\link[base]{character}} expected. Wellplan identification.
#' @description Check if the item "wellplan_id" have one unique class identified as character.
check_wellplan_id <- function(wellplan_id) {
if (length(x = class(x = wellplan_id)) != 1
|| ! inherits(x = wellplan_id,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"wellplan_id\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_sample_id
#' @title Attribute "sample_id" verification
#' @param sample_id Object of class {\link[base]{character}} expected. Sample identification.
#' @description Check if the item "sample_id" have one unique class identified as character.
check_sample_id <- function(sample_id) {
if (length(x = class(x = sample_id)) != 1
|| ! inherits(x = sample_id,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_id\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_elementarysampleraw_id
#' @title Attribute "elementarysampleraw_id" verification
#' @param elementarysampleraw_id Object of class {\link[base]{character}} expected. Elementary sample raw identification.
#' @description Check if the item "elementarysampleraw_id" have one unique class identified as character.
check_elementarysampleraw_id <- function(elementarysampleraw_id) {
if (length(x = class(x = elementarysampleraw_id)) != 1
|| ! inherits(x = elementarysampleraw_id,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"elementarysampleraw_id\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_well_id
#' @title Attribute "well_id" verification
#' @param well_id Object of class {\link[base]{character}} expected. Well identification.
#' @description Check if the item "well_id" have one unique class identified as character.
check_well_id <- function(well_id) {
if (length(x = class(x = well_id)) != 1
|| ! inherits(x = well_id,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"well_id\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_activity_id
#' @title Attribute "activity_id" verification
#' @param activity_id Object of class {\link[base]{character}} expected. Activity identification.
#' @description Check if the item "activity_id" have one unique class identified as character.
check_activity_id <- function(activity_id) {
if (length(x = class(x = activity_id)) != 1
|| ! inherits(x = activity_id,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"activity_id\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_elementarylanding_id
#' @title Attribute "elementarylanding_id" verification
#' @param elementarylanding_id Object of class {\link[base]{character}} expected. Elementary landing identification.
#' @description Check if the item "elementarylanding_id" have one unique class identified as character.
check_elementarylanding_id <- function(elementarylanding_id) {
if (length(x = class(x = elementarylanding_id)) != 1
|| ! inherits(x = elementarylanding_id,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"elementarylanding_id\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_elementarycatch_id
#' @title Attribute "elementarycatch_id" verification
#' @param elementarycatch_id Object of class {\link[base]{character}} expected. Elementary catch identification.
#' @description Check if the item "elementarycatch_id" have one unique class identified as character.
check_elementarycatch_id <- function(elementarycatch_id) {
if (length(x = class(x = elementarycatch_id)) != 1
|| ! inherits(x = elementarycatch_id,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"elementarycatch_id\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_sub_sample_id
#' @title Attribute "sub_sample_id" verification
#' @param sub_sample_id Object of class {\link[base]{integer}} expected. Sub sample identification.
#' @description Check if the item "sub_sample_id" have one unique class identified as integer.
check_sub_sample_id <- function(sub_sample_id) {
if (length(x = class(x = sub_sample_id)) != 1
|| ! inherits(x = sub_sample_id,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sub_sample_id\" argument, class integer expected.\n",
sep = "")
stop()
}
}
#' @name check_sub_sample_id_total_count
#' @title Attribute "sub_sample_id_total_count" verification
#' @param sub_sample_id_total_count Object of class {\link[base]{character}} expected. Sub sample identification bis in relation with the fish total count.
#' @description Check if the item "sub_sample_id_total_count" have one unique class identified as character.
check_sub_sample_id_total_count <- function(sub_sample_id_total_count) {
if (length(x = class(x = sub_sample_id_total_count)) != 1
|| ! inherits(x = sub_sample_id_total_count,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sub_sample_id_total_count\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_landing_category
#' @title Attribute "landing_category" verification
#' @param landing_category Object of class {\link[base]{character}} expected. Landing category identification.
#' @description Check if the item "landing_category" have one unique class identified as integer.
check_landing_category <- function(landing_category) {
if (length(x = class(x = landing_category)) != 1
|| ! inherits(x = landing_category,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"landing_category\" argument, class integer expected.\n",
sep = "")
stop()
}
}
#' @name check_landing_category_name
#' @title Attribute "landing_category_name" verification
#' @param landing_category_name Object of class {\link[base]{character}} expected. Landing category name identification.
#' @description Check if the item "landing_category_name" have one unique class identified as character.
check_landing_category_name <- function(landing_category_name) {
if (length(x = class(x = landing_category_name)) != 1
|| ! inherits(x = landing_category_name,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"landing_category_name\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_landing_date
#' @title Attribute "landing_date" verification
#' @param landing_date Object of class {\link[base]{character}} expected. Landing date in format year month day hour minute second UTC.
#' @description Check if the item "landing_date" is in date format year month day hour minute second UTC and check if the value is inferior to the actual date.
#' @importFrom lubridate ymd_hms
check_landing_date <- function(landing_date) {
if (is.na(x = lubridate::ymd_hms(landing_date,
quiet = TRUE,
tz = "UTC"))) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"landing_date\" argument, at least one item failed to parse with the expected format.\n",
sep = "")
stop()
} else if (lubridate::ymd_hms(landing_date,
quiet = TRUE,
tz = "UTC") > as.POSIXct(x = Sys.time(),
tz = "UTC")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: at least one \"landing_date\" is superior to the actual date.\n",
sep = "")
stop()
}
}
#' @name check_activity_date
#' @title Attribute "activity_date" verification
#' @param activity_date Object of class {\link[base]{character}} expected. Activity date in format year month day.
#' @param landing_date Object of class {\link[base]{character}} expected. Landing date in format year month day hour minute second UTC. By default NULL.
#' @description Check if the item "activity_date" is in date format year month day, if the value is inferior to the actual date and if it is inferior to the landing_date (if there are provided).
#' @importFrom lubridate ymd ymd_hms
check_activity_date <- function(activity_date,
landing_date = NULL) {
if (is.na(x = lubridate::ymd(activity_date,
quiet = TRUE))) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"activity_date\" argument, At least one item failed to parse with format \"ymd\".\n",
sep = "")
stop()
} else if (lubridate::ymd(activity_date,
quiet = TRUE) > Sys.Date()) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: at least one item \"activity_date\" is superior to the actual date.\n",
sep = "")
stop()
} else if (! is.null(x = landing_date)) {
if (is.na(lubridate::ymd_hms(landing_date,
quiet = TRUE,
tz = "UTC"))) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"landing_date\" argument, at least one item failed to parse with the expected format.\n",
sep = "")
stop()
} else if (lubridate::ymd(activity_date,
quiet = TRUE) > lubridate::ymd_hms(landing_date,
quiet = TRUE,
tz = "UTC")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: At least one \"activity_date\" is superior to \"landing_date\".\n",
sep = "")
stop()
}
}
}
#' @name check_departure_date
#' @title Attribute "departure_date" verification
#' @param departure_date Object of class {\link[base]{character}} expected. Departure date in format year month day hour minute second UTC.
#' @param landing_date Object of class {\link[base]{character}} expected. Landing date in format year month day hour minute second UTC. By default NULL.
#' @description Check if the item "departure_date" is in date format year month day hour minute second UTC, if the value is inferior to the actual date and if it is inferior to the landing_date (if there are provided).
#' @importFrom lubridate ymd
check_departure_date <- function(departure_date,
landing_date = NULL) {
if (is.na(x = lubridate::ymd_hms(departure_date,
quiet = TRUE,
tz = "UTC"))) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"departure_date\" argument, at least one item failed to parse with the expected format.\n",
sep = "")
stop()
} else if (lubridate::ymd_hms(departure_date,
quiet = TRUE,
tz = "UTC") > as.POSIXct(x = Sys.time(),
tz = "UTC")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: at least one item \"departure_date\" is superior to the actual date.\n",
sep = "")
stop()
} else if (! is.null(x = landing_date)) {
if (is.na(lubridate::ymd_hms(landing_date,
quiet = TRUE,
tz = "UTC"))) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"landing_date\" argument, at least one item failed to parse with the expected format.\n",
sep = "")
stop()
} else if (lubridate::ymd_hms(departure_date,
quiet = TRUE,
tz = "UTC") > lubridate::ymd_hms(landing_date,
quiet = TRUE,
tz = "UTC")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: At least one \"departure_date\" is superior to \"landing_date\".\n",
sep = "")
stop()
}
}
}
#' @name check_logbook_availability
#' @title Attribute "logbook_availability" verification
#' @param logbook_availability Object of class {\link[base]{integer}} expected. Logbook availability value, 1 for available and 0 for not.
#' @description Check if the item "logbook_availability" is class integer and if all values are 1 or 0.
check_logbook_availability <- function(logbook_availability) {
if (length(x = class(x = logbook_availability)) != 1
|| ! inherits(x = logbook_availability,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"logbook_availability\" argument, class integer expected.\n",
sep = "")
stop()
} else if (! logbook_availability %in% c(0, 1)) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"logbook_availability\" argument, value 0 or 1 expected.\n",
sep = "")
stop()
}
}
#' @name check_fish_hold_empty
#' @title Attribute "fish_hold_empty" verification
#' @param fish_hold_empty Object of class {\link[base]{integer}} expected. Inform if the fish hold empty at the end of the trip, 1 for yes and 0 for not.
#' @description Check if the item "fish_hold_empty" is class integer and if all values are 1 or 0.
check_fish_hold_empty <- function(fish_hold_empty) {
if (length(x = class(fish_hold_empty)) != 1
|| ! inherits(x = fish_hold_empty,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"fish_hold_empty\" argument, class integer expected.\n",
sep = "")
stop()
} else if (! fish_hold_empty %in% c(0, 1)) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"fish_hold_empty\" argument, value 0 or 1 expected.\n",
sep = "")
stop()
}
}
#' @name check_vessel_id
#' @title Attribute "vessel_id" verification
#' @param vessel_id Object of class {\link[base]{integer}} expected. Vessel identification.
#' @description Check if the item "vessel_id" have one unique class identified as integer.
check_vessel_id <- function(vessel_id) {
if (length(x = class(x = vessel_id)) != 1
|| ! inherits(x = vessel_id,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"vessel_id\" argument, class integer expected.\n",
sep = "")
stop()
}
}
#' @name check_vessel_type
#' @title Attribute "vessel_type" verification
#' @param vessel_type Object of class {\link[base]{character}} expected. Vessel type identification.
#' @description Check if the item "vessel_type" have one unique class identified as character.
check_vessel_type <- function(vessel_type) {
if (length(x = class(x = vessel_type)) != 1
|| ! inherits(x = vessel_type,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"vessel_type\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_activity_number
#' @title Attribute "activity_number" verification
#' @param activity_number Object of class {\link[base]{integer}} expected. Activity number.
#' @description Check if the item "activity_number" have one unique class identified as integer.
check_activity_number <- function(activity_number) {
if (length(x = class(x = activity_number)) != 1
|| ! inherits(x = activity_number,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"activity_number\" argument, class integer expected.\n",
sep = "")
stop()
}
}
#' @name check_ocean
#' @title Attribute "ocean" verification
#' @param ocean Object of class {\link[base]{integer}} expected. Ocean identification.
#' @description Check if the item "ocean" is class integer and if all values are 1, 2, 3, 4 or 5.
check_ocean <- function(ocean) {
if (length(x = class(x = ocean)) != 1
|| ! inherits(x = ocean,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"ocean\" argument, class integer expected.\n",
sep = "")
stop()
} else if (! ocean %in% c(1, 2, 3, 4, 5)) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"ocean\" argument, value 1, 2, 3, 4 or 5 expected.\n",
sep = "")
stop()
}
}
#' @name check_length_type
#' @title Attribute "length_type" verification
#' @param length_type Object of class {\link[base]{integer}} expected. Length type identification, 1 for LD1 and 2 for LF.
#' @description Check if the item "length_type" is class integer and if all values are 1 or 2.
check_length_type <- function(length_type) {
if (length(x = class(x = length_type)) != 1
|| ! inherits(x = length_type,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"length_type\" argument, class integer expected.\n",
sep = "")
stop()
} else if (! length_type %in% c(1, 2)) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"length_type\" argument, value 1 or 2 expected.\n",
sep = "")
stop()
}
}
#' @name check_school_type
#' @title Attribute "school_type" verification
#' @param school_type Object of class {\link[base]{integer}} expected. School type identification.
#' @description Check if the item "school_type" is class integer and if all values are 1, 2, or 3.
check_school_type <- function(school_type) {
if (length(x = class(x = school_type)) != 1
|| ! inherits(x = school_type,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"school_type\" argument, class integer expected.\n",
sep = "")
stop()
} else if (! school_type %in% c(1, 2, 3)) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"school_type\" argument, value 1, 2 or 3 expected.\n",
sep = "")
stop()
}
}
#' @name check_logbook_category
#' @title Attribute "logbook_category" verification
#' @param logbook_category Object of class {\link[base]{integer}} expected. Logbook weight category.
#' @description Check if the item "logbook_category" have one unique class identified as integer and if values are between 1 and 13.
check_logbook_category <- function(logbook_category) {
if (length(x = class(x = logbook_category)) != 1
|| ! inherits(x = logbook_category,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"logbook_category\" argument, class integer expected.\n",
sep = "")
stop()
} else if (! logbook_category %in% c(1:13)) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"logbook_category\" argument, value from 1 to 13 expected.\n",
sep = "")
stop()
}
}
#' @name check_logbook_category_name
#' @title Attribute "logbook_category_name" verification
#' @param logbook_category_name Object of class {\link[base]{character}} expected. Logbook category name identification.
#' @description Check if the item "logbook_category_name" have one unique class identified as character.
check_logbook_category_name <- function(logbook_category_name) {
if (length(x = class(x = logbook_category_name)) != 1
|| ! inherits(x = logbook_category_name,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"logbook_category_name\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_specie_code3l
#' @title Attribute "specie_code3l" verification
#' @param specie_code3l Object of class {\link[base]{character}} expected. Specie code identification on 3 characters.
#' @description Check if the item "specie_code3l" have one unique class identified as character and 3 characters.
check_specie_code3l <- function(specie_code3l) {
if (length(x = class(x = specie_code3l)) != 1
|| ! inherits(x = specie_code3l,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"specie_code3l\" argument, class character expected.\n",
sep = "")
stop()
} else if (nchar(x = specie_code3l) != 3) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"specie_code3l\" argument, 3 character expected.\n",
sep = "")
stop()
}
}
#' @name check_specie_code
#' @title Attribute "specie_code" verification
#' @param specie_code Object of class {\link[base]{integer}} expected. Specie code identification.
#' @description Check if the item "specie_code" have one unique class identified as integer and superior to zero.
check_specie_code <- function(specie_code) {
if (length(x = class(x = specie_code)) != 1
|| ! inherits(x = specie_code,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"specie_code\" argument, class integer expected.\n",
sep = "")
stop()
} else if (specie_code <= 0) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"specie_code\" argument, integer expected with value superior to zero.\n",
sep = "")
stop()
}
}
#' @name check_activity_name
#' @title Attribute "activity_name" verification
#' @param activity_name Object of class {\link[base]{character}} expected. Activity identification.
#' @description Check if the item "check_activity_name" have one unique class identified as character.
check_activity_name <- function(activity_name) {
if (length(x = class(x = activity_name)) != 1
|| ! inherits(x = activity_name,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"activity_name\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_fleet
#' @title Attribute "fleet" verification
#' @param fleet Object of class {\link[base]{character}} expected. Fleet identification.
#' @description Check if the item "fleet" have one unique class identified as character.
check_fleet <- function(fleet) {
if (length(x = class(x = fleet)) != 1
|| ! inherits(x = fleet,
what = "character")) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"fleet\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_wellplan_weigth_category_label
#' @title Attribute "wellplan_weigth_category_label" verification
#' @param wellplan_weigth_category_label Object of class {\link[base]{character}} expected. Well plan weight category identification.
#' @description Check if the item "wellplan_weigth_category_label" have one unique class identified as character.
check_wellplan_weigth_category_label <- function(wellplan_weigth_category_label) {
if (length(x = class(x = wellplan_weigth_category_label)) != 1
|| ! inherits(x = wellplan_weigth_category_label,
what = "character")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"wellplan_weigth_category_label\" argument, class character expected.\n",
sep = "")
stop()
}
}
#' @name check_activity_code
#' @title Attribute "activity_code" verification
#' @param activity_code Object of class {\link[base]{integer}} expected. Activity code identification.
#' @description Check if the item "activity_code" have one unique class identified as integer.
check_activity_code <- function(activity_code) {
if (length(x = class(x = activity_code)) != 1
|| ! inherits(x = activity_code,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"activity_code\" argument, class integer expected.\n",
sep = "")
stop()
}
}
#' @name check_wellplan_number
#' @title Attribute "wellplan_number" verification
#' @param wellplan_number Object of class {\link[base]{integer}} expected. Well plan number of individus.
#' @description Check if the item "wellplan_number" have one unique class identified as integer.
check_wellplan_number <- function(wellplan_number) {
if (length(x = class(x = wellplan_number)) != 1
|| ! inherits(x = wellplan_number,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"wellplan_number\" argument, class integer expected.\n",
sep = "")
stop()
}
}
#' @name check_catch_weight
#' @title Attribute "catch_weight" verification
#' @param catch_weight Object of class {\link[base]{numeric}} expected. Catch weight in tonnes.
#' @description Check if the item "catch_weight" have one unique class identified as numeric and if values are superior to zero.
check_catch_weight <- function(catch_weight) {
if (length(x = class(x = catch_weight)) != 1
|| ! inherits(x = catch_weight,
what = "numeric")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"catch_weight\" argument, class numeric expected.\n",
sep = "")
stop()
} else if (catch_weight <= 0) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"catch_weight\" argument, positive value expected.\n",
sep = "")
stop()
}
}
#' @name check_well_minus10_weigth
#' @title Attribute "well_minus10_weigth" verification
#' @param well_minus10_weigth Object of class {\link[base]{integer}} expected. Catch weight of individus less than 10 tonnes (by well, in tonne, all species considerated).
#' @description Check if the item "well_minus10_weigth" have one unique class identified as integer and if value are >= 0.
check_well_minus10_weigth <- function(well_minus10_weigth) {
if (length(class(well_minus10_weigth)) != 1
|| ! inherits(x = well_minus10_weigth,
what = "integer")) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"well_minus10_weigth\" argument, class integer expected.\n",
sep = "")
stop()
} else if (well_minus10_weigth < 0) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"well_minus10_weigth\" argument, 0 or postive value expected.\n",
sep = "")
stop()
}
}
#' @name check_weighted_weight
#' @title Attribute "weighted_weight" verification
#' @param weighted_weight Object of class {\link[base]{numeric}} Set weight weighted by all set in the well(s).
#' @description Check if the item "weighted_weight" have one unique class identified as numeric and if value are >= 0.
check_weighted_weight <- function(weighted_weight) {
if (length(class(weighted_weight)) != 1
|| ! inherits(x = weighted_weight,
what = "numeric")) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"weighted_weight\" argument, class numeric expected.\n",
sep = "")
stop()
} else if (weighted_weight <= 0) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"weighted_weight\" argument, postive value expected.\n",
sep = "")
stop()
}
}
#' @name check_well_plus10_weigth
#' @title Attribute "well_plus10_weigth" verification
#' @param well_plus10_weigth Object of class {\link[base]{integer}} expected. Catch weight of individus more than 10 tonnes (by well, in tonne, all species considerated).
#' @description Check if the item "well_plus10_weigth" have one unique class identified as integer and if value are >= 0.
check_well_plus10_weigth <- function(well_plus10_weigth) {
if (length(class(well_plus10_weigth)) != 1
|| ! inherits(x = well_plus10_weigth,
what = "integer")) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"well_plus10_weigth\" argument, class integer expected.\n",
sep = "")
stop()
} else if (well_plus10_weigth < 0) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"well_plus10_weigth\" argument, 0 or postive value expected.\n",
sep = "")
stop()
}
}
#' @name check_well_global_weigth
#' @title Attribute "well_global_weigth" verification
#' @param well_global_weigth Object of class {\link[base]{integer}} expected. Catch weight of individus (less and more 10 tonnes categories, by well, in tonne, all species considerated).
#' @description Check if the item "well_global_weigth" have one unique class identified as integer and if value are >= 0.
check_well_global_weigth <- function(well_global_weigth) {
if (length(class(well_global_weigth)) != 1
|| ! inherits(x = well_global_weigth,
what = "integer")) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"well_global_weigth\" argument, class integer expected.\n",
sep = "")
stop()
} else if (well_global_weigth < 0) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"well_global_weigth\" argument, 0 or postive value expected.\n",
sep = "")
stop()
}
}
#' @name check_landing_weight
#' @title Attribute "landing_weight" verification
#' @param landing_weight Object of class {\link[base]{numeric}} expected. Landing weight in tonnes.
#' @description Check if the item "landing_weight" have one unique class identified as numeric.
check_landing_weight <- function(landing_weight) {
if (length(x = class(x = landing_weight)) != 1
|| ! inherits(x = landing_weight,
what = "numeric")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"landing_weight\" argument, class numeric expected.\n",
sep = "")
stop()
}
}
#' @name check_set_count
#' @title Attribute "set_count" verification
#' @param set_count Object of class {\link[base]{integer}} expected. Number of set associated to the activity.
#' @description Check if the item "set_count" have one unique class identified as integer and if value are superior or equal to 0
check_set_count <- function(set_count) {
if (length(x = class(x = set_count)) != 1
|| ! inherits(x = set_count,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"set_count\" argument, class integer expected.\n",
sep = "")
stop()
} else if (set_count < 0) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"set_count\" argument, 0 or postive value expected.\n",
sep = "")
stop()
}
}
#' @name check_time_at_sea
#' @title Attribute "time_at_sea" verification
#' @param time_at_sea Object of class {\link[base]{integer}} expected. Time at sea in hours.
#' @description Check if the item "time_at_sea" have one unique class identified as integer and if all values are superior or egal to zero.
check_time_at_sea <- function(time_at_sea) {
if (length(x = class(x = time_at_sea)) != 1
|| ! inherits(x = time_at_sea,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"time_at_sea\" argument, class integer expected.\n",
sep = "")
stop()
} else if (time_at_sea < 0) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"time_at_sea\" argument, 0 or postive value expected.\n",
sep = "")
stop()
}
}
#' @name check_sample_total_count
#' @title Attribute "sample_total_count" verification
#' @param sample_total_count Object of class {\link[base]{integer}} expected. Sample number of total individuals counted.
#' @description Check if the item "sample_total_count" have one unique class identified as integer and if all values are positive and different of zero.
check_sample_total_count <- function(sample_total_count) {
if (length(x = class(x = sample_total_count)) != 1
|| ! inherits(x = sample_total_count,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_total_count\" argument, class integer expected.\n",
sep = "")
stop()
} else if (sample_total_count <= 0) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_total_count\" argument, postive value (without zero) expected.\n",
sep = "")
stop()
}
}
#' @name check_sample_number_measured
#' @title Attribute "sample_number_measured" verification
#' @param sample_number_measured Object of class {\link[base]{integer}} expected. Sample number of measured individus.
#' @description Check if the item "sample_number_measured" have one unique class identified as integer and if all values are positive and different of zero.
check_sample_number_measured <- function(sample_number_measured) {
if (length(x = class(x = sample_number_measured)) != 1
|| ! inherits(x = sample_number_measured,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_number_measured\" argument, class integer expected.\n",
sep = "")
stop()
} else if (sample_number_measured <= 0) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_number_measured\" argument, postive value (without zero) expected.\n",
sep = "")
stop()
}
}
#' @name check_sample_number_measured_extrapolated_lf
#' @title Attribute "sample_number_measured_extrapolated_lf" verification
#' @param sample_number_measured_extrapolated_lf Object of class {\link[base]{numeric}} Sample number of measured individus extrapolated to all counted individus.
#' @description Check if the item "sample_number_measured_extrapolated_lf" have one unique class identified as numeric and if all values are positive and different of zero.
check_sample_number_measured_extrapolated_lf <- function(sample_number_measured_extrapolated_lf) {
if (length(class(sample_number_measured_extrapolated_lf)) != 1
|| ! inherits(x = sample_number_measured_extrapolated_lf,
what = "numeric")) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_number_measured_extrapolated_lf\" argument, class numeric expected.\n",
sep = "")
stop()
} else if (sample_number_measured_extrapolated_lf <= 0) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_number_measured_extrapolated_lf\" argument, postive value (without zero) expected.\n",
sep = "")
stop()
}
}
#' @name check_sample_number_weighted
#' @title Attribute "sample_number_weighted" verification
#' @param sample_number_weighted Object of class {\link[base]{numeric}} Sample number of measured individus extrapolated to all counted individus and weighted by set weight.
#' @description Check if the item "sample_number_weighted" have one unique class identified as numeric and if all values are positive and different of zero.
check_sample_number_weighted <- function(sample_number_weighted) {
if (length(class(sample_number_weighted)) != 1
|| ! inherits(x = sample_number_weighted,
what = "numeric")) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_number_weighted\" argument, class numeric expected.\n",
sep = "")
stop()
} else if (sample_number_weighted <= 0) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_number_weighted\" argument, postive value (without zero) expected.\n",
sep = "")
stop()
}
}
#' @name check_wellplan_weight
#' @title Attribute "wellplan_weight" verification
#' @param wellplan_weight Object of class {\link[base]{numeric}} Weight in tonnes filled in the well plan.
#' @description Check if the item "wellplan_weight" have one unique class identified as numeric and if all values are positive and different of zero.
check_wellplan_weight <- function(wellplan_weight) {
if (length(x = class(x = wellplan_weight)) != 1
|| ! inherits(x = wellplan_weight,
what = "numeric")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"wellplan_weight\" argument, class numeric expected.\n",
sep = "")
stop()
} else if (wellplan_weight <= 0) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"wellplan_weight\" argument, postive value (without zero) expected.\n",
sep = "")
stop()
}
}
#' @name check_sample_length_class
#' @title Attribute "sample_length_class" verification
#' @param sample_length_class Object of class {\link[base]{integer}} expected. Sample length class of measured individus.
#' @description Check if the item "sample_length_class" have one unique class identified as integer and if all values are positive and different of zero.
check_sample_length_class <- function(sample_length_class) {
if (length(x = class(x = sample_length_class)) != 1
|| ! inherits(x = sample_length_class,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_length_class\" argument, class integer expected.\n",
sep = "")
stop()
} else if (sample_length_class <= 0) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_length_class\" argument, postive value (without zero) expected.\n",
sep = "")
stop()
}
}
#' @name check_sample_quality
#' @title Attribute "sample_quality" verification
#' @param sample_quality Object of class {\link[base]{integer}} expected. Sample quality identification.
#' @description Check if the item "sample_quality" have one unique class identified as integer and if all values are 1, 2, 3, 4 or 9.
check_sample_quality <- function(sample_quality) {
if (length(x = class(x = sample_quality)) != 1
|| ! inherits(x = sample_quality,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_quality\" argument, class integer expected.\n",
sep = "")
stop()
} else if (! sample_quality %in% c(1, 2, 3, 4, 9)) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_quality\" argument, value 1, 2, 3, 4 or 9 expected.\n",
sep = "")
stop()
}
}
#' @name check_sample_type
#' @title Attribute "sample_type" verification
#' @param sample_type Object of class {\link[base]{integer}} expected. Sample type identification.
#' @description Check if the item "sample_type" have one unique class identified as integer and if all values are 1, 2, 3, 4, 9 or 11.
check_sample_type <- function(sample_type) {
if (length(x = class(x = sample_type)) != 1
|| ! inherits(x = sample_type,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_type\" argument, class integer expected.\n",
sep = "")
stop()
} else if (! sample_type %in% c(1, 2, 3, 4, 9, 11)) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_type\" argument, value 1, 2, 3, 4, 9 or 11 expected.\n",
sep = "")
stop()
}
}
#' @name check_wellplan_weigth_category_code
#' @title Attribute "wellplan_weigth_category_code" verification
#' @param wellplan_weigth_category_code Object of class {\link[base]{integer}} expected. Well plan category code identification.
#' @description Check if the item "wellplan_weigth_category_code" have one unique class identified as integer and if all values are 1, 2, 8 or 9.
check_wellplan_weigth_category_code <- function(wellplan_weigth_category_code) {
if (length(x = class(x = wellplan_weigth_category_code)) != 1
|| ! inherits(x = wellplan_weigth_category_code,
what = "integer")) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"wellplan_weigth_category_code\" argument, class integer expected.\n",
sep = "")
stop()
} else if (! wellplan_weigth_category_code %in% c(1, 2, 8, 9)) {
cat(format(x = Sys.time(),
format = "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"wellplan_weigth_category_code\" argument, value 1, 2, 8 or 9 expected.\n",
sep = "")
stop()
}
}
#' @name check_sample_standardised_length_class_lf
#' @title Attribute "sample_standardised_length_class_lf" verification
#' @param sample_standardised_length_class_lf Object of class {\link[base]{integer}} expected. Sample standardised length class length fork of measured individus.
#' @description Check if the item "sample_standardised_length_class_lf" have one unique class identified as integer and if all values are positive and different of zero.
check_sample_standardised_length_class_lf <- function(sample_standardised_length_class_lf) {
if (length(class(sample_standardised_length_class_lf)) != 1
|| ! inherits(x = sample_standardised_length_class_lf,
what = "integer")) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_standardised_length_class_lf\" argument, class integer expected.\n",
sep = "")
stop()
} else if (sample_standardised_length_class_lf < 0) {
cat(format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
" - Error: invalide \"sample_standardised_length_class_lf\" argument, postive value expected.\n",