-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathstandardize.R
More file actions
72 lines (51 loc) · 2.24 KB
/
standardize.R
File metadata and controls
72 lines (51 loc) · 2.24 KB
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
#######################################################################################################################################
#### R code to standardize spatio-temporal and taxa per survey
#### Coding: Laura Mannocci (laura.mannocci@fondationbiodiversite.fr) and Nicolas Casajus (nicolas.casajus@fondationbiodiversite.fr)
#### Updated December 2022 by Aurore
#######################################################################################################################################
######### Preliminary steps
#install required packages that are not already installed
required_packages <- c("data.table",
"devtools",
"dggridR",
"dplyr",
"fields",
"forcats",
"ggplot2",
"here",
"magrittr",
"maps",
"maptools",
"raster",
"rcompendium",
"readr",
"remotes",
"rrtools",
"sf",
"sp",
"tidyr",
"usethis")
not_installed <- required_packages[!(required_packages %in% installed.packages()[ , "Package"])]
if(length(not_installed)) install.packages(not_installed)
#load pipe operator
library(magrittr)
#load all functions
source(here::here("standardization_steps", "functions.R"))
######### Read FISHGLOB data
# function from Laura M.
dat <- read_clean_data()
######### Apply taxonomic flagging per region
#get vector of regions (here the survey column)
regions <- levels(as.factor(dat$survey))
#run flag_spp function in a loop
for (r in regions) {
flag_spp(dat, r)
}
######### Apply trimming per survey_unit method 1
#apply trimming for hex size 7
# removed one haul without long lats because otherwise the function does not work!
dat_new_method1_hex7 <- apply_trimming_per_survey_unit_method1(dat, 7)
#apply trimming for hex size 8
dat_new_method1_hex8 <- apply_trimming_per_survey_unit_method1(dat, 8)
######### Apply trimming per survey_unit method 2
dat_new_method2 <- apply_trimming_per_survey_unit_method2(dat)