annotate cb_ivr.r @ 1:b67730406f1b draft

planemo upload for repository https://github.com/Marie59/champ_blocs commit 0d86db7d42b608c386a54500064f5f9c9d7019a4
author ecology
date Wed, 04 Jan 2023 13:21:30 +0000
parents 8c6142630659
children bcbad4f83dec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
1 # author: "Jonathan Richir"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
2 # date: "19 April 2021" )
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
3
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
4 #Rscript
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
5
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
6 ###############################
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
7 ## ##
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
8 ###############################
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
9
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
10 #####Packages : dplyr
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
11 # tidyr
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
12 # readr
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
13 # writexl
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
14 # stringr
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
15 # readxl
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
16 # tibble
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
17 # lubridate
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
18 # cowplot
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
19 # magrittr
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
20 # rmarkdown
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
21 library(magrittr)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
22 #####Load arguments
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
23
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
24 args <- commandArgs(trailingOnly = TRUE)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
25
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
26 ### Import data
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
27
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
28 if (length(args) < 1) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
29 stop("This tool needs at least 1 argument")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
30 }else {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
31 fiche_val <- args[1]
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
32 input_data <- args[2]
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
33
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
34 }
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
35
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
36 #############################################################
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
37 # #
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
38 # Load and clean the data #
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
39 # #
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
40 #############################################################
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
41 ### load ivr data
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
42
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
43 ivr <- read.csv2(input_data, header = FALSE, fileEncoding = "Latin1")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
44 names_ <- as.vector(unlist(ivr[1, ]))
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
45 names_ <- gsub(" ", ".", names_)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
46 colnames(ivr) <- names_
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
47 ivr <- ivr[-1, ]
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
48 ivr <- ivr[, -17]
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
49
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
50 # NB inversion between id and ID.Fiche variable names
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
51 ivr <- dplyr::rename(ivr, XX = ID.Fiche)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
52 ivr <- dplyr::rename(ivr, ID.Fiche = id)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
53 ivr <- dplyr::rename(ivr, id = XX)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
54
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
55
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
56 ### load excel files "Fiche terrain" the metadata
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
57
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
58 fiche <- read.csv2(fiche_val, fileEncoding = "Latin1") # fileEncoding = "Latin1" cfr é in variable names
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
59
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
60 date_fiche <- as.Date(stringr::str_sub(fiche$date.sortie, end = 10), origin = "1970-01-01")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
61 fiche <- tibble::add_column(fiche, date_fiche, .after = "date.sortie")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
62 rm(date_fiche)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
63
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
64 ## ivr vs fiche terrain
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
65 ivr$id <- as.numeric(ivr[, c("id")])
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
66
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
67 fiche_red <- dplyr::filter(fiche, fiche$ID.Fiche %in% unique(ivr[, c("id")]))
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
68
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
69 id_count <- ivr %>% dplyr::group_by(id) %>% dplyr::count()
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
70 id_count <- dplyr::rename(id_count, "ID.Fiche" = "id")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
71 id_count <- dplyr::ungroup(id_count)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
72 id_count <- as.data.frame(id_count)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
73
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
74 fiche_red <- dplyr::left_join(fiche_red, id_count)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
75
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
76 # rep fiche terrain information
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
77 fiche_expanded <- fiche_red[rep(row.names(fiche_red), fiche_red$n), 1:ncol(fiche_red)]
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
78 fiche_expanded <- dplyr::rename(fiche_expanded, "id" = "ID.Fiche")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
79
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
80 ## merge ivr data and ficheterrain information
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
81 ivr <- dplyr::bind_cols(ivr, fiche_expanded)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
82 ivr <- dplyr::rename(ivr, "id.ivr" = "id...1")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
83 ivr <- dplyr::rename(ivr, "id.fiche" = "id...17")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
84
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
85 rm(fiche_expanded, fiche_red, id_count)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
86
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
87 ivr <- ivr %>% tidyr::separate(date_fiche, c("Year", "Month", "Day"), sep = "-", remove = FALSE)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
88
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
89 ## I create two new variables for Site names, one for data analysis and one for data reporting. Only works for actual ivr df with 22 sites !
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
90
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
91 # Name for data analysis
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
92 ivr <- tibble::add_column(ivr, Site = ivr$zone.habitat, .after = "ID.Fiche")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
93 ivr$Site <- gsub(pattern = " \\(champ de blocs\\)", replacement = "", ivr$Site)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
94 ivr$Site <- gsub(pattern = " \\(champ blocs\\)", replacement = "", ivr$Site)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
95
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
96 for (x in seq_along(ivr$Site)) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
97 if (grepl(pattern = "Locmariaquer", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
98 ivr$Site[x] <- "GDMO_Locmariaquer"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
99 } else if (grepl(pattern = "Beg Lann", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
100 ivr$Site[x] <- "GDMO_BegLann"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
101 } else if (grepl(pattern = "Plateau du Four", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
102 ivr$Site[x] <- "FOUR_PlateauFour"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
103 } else if (grepl(pattern = "Grouin", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
104 ivr$Site[x] <- "EGMP_GroinCou"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
105 } else if (grepl(pattern = "Ensembert", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
106 ivr$Site[x] <- "EGMP_PasEmsembert"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
107 } else if (grepl(pattern = "Brée-les-Bains", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
108 ivr$Site[x] <- "EGMP_BreeBains"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
109 } else if (grepl(pattern = "Antiochat", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
110 ivr$Site[x] <- "EGMP_PerreAntiochat"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
111 } else if (grepl(pattern = "Chassiron", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
112 ivr$Site[x] <- "EGMP_Chassiron"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
113 } else if (grepl(pattern = "zone p", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
114 ivr$Site[x] <- "BASQ_FlotsBleusZP"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
115 } else if (grepl(pattern = "zone f", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
116 ivr$Site[x] <- "BASQ_FlotsBleusZF"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
117 } else if (grepl(pattern = "Saint-Michel", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
118 ivr$Site[x] <- "GONB_IlotStMichel"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
119 } else if (grepl(pattern = "Quéménès", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
120 ivr$Site[x] <- "FINS_Quemenes"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
121 } else if (grepl(pattern = "Goulenez", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
122 ivr$Site[x] <- "FINS_SeinGoulenez"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
123 } else if (grepl(pattern = "Kilaourou", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
124 ivr$Site[x] <- "FINS_SeinKilaourou"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
125 } else if (grepl(pattern = "Verdelet", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
126 ivr$Site[x] <- "ARMO_Verdelet"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
127 } else if (grepl(pattern = "Piégu", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
128 ivr$Site[x] <- "ARMO_Piegu"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
129 } else if (grepl(pattern = "Bilfot", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
130 ivr$Site[x] <- "ARMO_Bilfot"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
131 } else if (grepl(pattern = "Plate", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
132 ivr$Site[x] <- "ARMO_IlePlate"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
133 } else if (grepl(pattern = "Perharidy", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
134 ivr$Site[x] <- "PDMO_Perharidy"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
135 } else if (grepl(pattern = "Keraliou", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
136 ivr$Site[x] <- "BRES_Keraliou"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
137 } else if (grepl(pattern = "Mousterlin", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
138 ivr$Site[x] <- "FINS_Mousterlin"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
139 } else if (grepl(pattern = "Nicolas", ivr$Site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
140 ivr$Site[x] <- "FINS_StNicolasGlenan"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
141 }
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
142 if (grepl(pattern = "Roz", ivr$site[x]) == TRUE) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
143 ivr$Site[x] <- "FINS_AnseRoz"
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
144 }
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
145 }
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
146
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
147 # Name for report/plot
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
148
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
149 ivr <- tibble::add_column(ivr, Site_bis = ivr$Site, .after = "Site")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
150
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
151 ivr$Site_bis <- ifelse(ivr$Site == "GDMO_Locmariaquer", "Locmariaquer", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
152 ivr$Site_bis <- ifelse(ivr$Site == "GDMO_BegLann", "Beg Lann", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
153 ivr$Site_bis <- ifelse(ivr$Site == "FOUR_PlateauFour", "Plateau du Four", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
154 ivr$Site_bis <- ifelse(ivr$Site == "EGMP_GroinCou", "Grouin du Cou", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
155 ivr$Site_bis <- ifelse(ivr$Site == "EGMP_PasEmsembert", "Le Pas d'Emsembert", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
156 ivr$Site_bis <- ifelse(ivr$Site == "EGMP_BreeBains", "La Brée-les-Bains", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
157 ivr$Site_bis <- ifelse(ivr$Site == "EGMP_PerreAntiochat", "Le Perré d'Antiochat", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
158 ivr$Site_bis <- ifelse(ivr$Site == "EGMP_Chassiron", "Chassiron", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
159 ivr$Site_bis <- ifelse(ivr$Site == "BASQ_FlotsBleusZP", "Les Flots Bleus / zone pêcheurs", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
160 ivr$Site_bis <- ifelse(ivr$Site == "BASQ_FlotsBleusZF", "Les Flots Bleus / zone familles", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
161 ivr$Site_bis <- ifelse(ivr$Site == "GONB_IlotStMichel", "Îlot Saint-Michel", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
162 ivr$Site_bis <- ifelse(ivr$Site == "FINS_Quemenes", "Quéménès", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
163 ivr$Site_bis <- ifelse(ivr$Site == "FINS_SeinGoulenez", "Île de Sein - Goulenez", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
164 ivr$Site_bis <- ifelse(ivr$Site == "FINS_SeinKilaourou", "Île de Sein - Kilaourou", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
165 ivr$Site_bis <- ifelse(ivr$Site == "ARMO_Verdelet", "Îlot du Verdelet", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
166 ivr$Site_bis <- ifelse(ivr$Site == "ARMO_Piegu", "Piégu", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
167 ivr$Site_bis <- ifelse(ivr$Site == "ARMO_Bilfot", "Pointe de Bilfot", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
168 ivr$Site_bis <- ifelse(ivr$Site == "ARMO_IlePlate", "Île Plate", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
169 ivr$Site_bis <- ifelse(ivr$Site == "PDMO_Perharidy", "Perharidy", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
170 ivr$Site_bis <- ifelse(ivr$Site == "BRES_Keraliou", "Keraliou", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
171 ivr$Site_bis <- ifelse(ivr$Site == "FINS_Mousterlin", "Pointe de Mousterlin", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
172 ivr$Site_bis <- ifelse(ivr$Site == "FINS_StNicolasGlenan", "Saint-Nicolas des Glénan", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
173 ivr$Site_bis <- ifelse(ivr$Site == "FINS_AnseRoz", "Pointe de l'Anse du Roz", ivr$Site_bis)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
174
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
175 ## change some variable format to integer
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
176 ivr$Nb.Blocs.Non.Retournes <- as.integer(ivr$Nb.Blocs.Non.Retournes)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
177 ivr$Nb.Blocs.Retournes <- as.integer(ivr$Nb.Blocs.Retournes)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
178
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
179 ivr$Year <- as.integer(ivr$Year)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
180 ivr$Month <- as.integer(ivr$Month)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
181 ivr$Day <- as.integer(ivr$Day)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
182 ivr$Numero.Quadrat <- as.integer(ivr$Numero.Quadrat)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
183
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
184
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
185 ## save the final, commplete ivr df.
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
186
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
187 ivr <- ivr[, c(19:54, 1:18)]
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
188
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
189
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
190 ## percentage of unturned vs overturned boulders and IVR previous 0-5 discrete scale values calculation
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
191
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
192 # create two new variables first
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
193 site_year_month_day <- paste0(ivr$Site, ".", gsub("-", ".", as.character(ivr$date_fiche)))
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
194 ivr <- tibble::add_column(ivr, site_year_month_day, .after = "Site_bis")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
195 rm(site_year_month_day)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
196
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
197 site_year_month_day_qdnb <- paste0(ivr$Site, ".", gsub("-", ".", as.character(ivr$Date)), ".", ivr$Numero.Quadrat)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
198 ivr <- tibble::add_column(ivr, site_year_month_day_qdnb, .after = "site_year_month_day")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
199 rm(site_year_month_day_qdnb)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
200
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
201 ivr <- dplyr::arrange(ivr, Site, Year, Month, Numero.Quadrat)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
202
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
203 # remove data with NA value for Nb.Blocs.Retournes & Nb.Blocs.Non.Retournes
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
204 ivr_naomit <- ivr %>% dplyr::filter(!is.na(ivr$Nb.Blocs.Retournes))
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
205 ivr_naomit <- as.data.frame(ivr_naomit)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
206 colnames(ivr_naomit) <- colnames(ivr)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
207 ivr_naomit <- ivr_naomit %>% dplyr::filter(!is.na(ivr_naomit$Nb.Blocs.Non.Retournes))
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
208 ivr_naomit <- as.data.frame(ivr_naomit)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
209
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
210 # also remove data with Nb.Blocs.Retournes = 0 & Nb.Blocs.Non.Retournes = 0, cfr equivalent to quadrat with no boulders ... makes no sense to consider quadrat without boulder for ivr determination.
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
211 ivr_rm <- dplyr::filter(ivr_naomit, ivr_naomit$Nb.Blocs.Retournes == 0 && ivr_naomit$Nb.Blocs.Non.Retournes == 0)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
212 ivr_naomit <- ivr_naomit %>% dplyr::anti_join(ivr_rm)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
213 rm(ivr_rm)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
214
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
215 ivr_val_qu_ <- ivr_naomit
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
216
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
217
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
218
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
219 #############################################################
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
220 # #
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
221 # Calcul of the IVR #
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
222 # #
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
223 #############################################################
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
224
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
225 ### Percentage of turned boulder
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
226 for (i in 1:nrow(ivr_naomit)) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
227 (bm <- sum(ivr_naomit$Nb.Blocs.Non.Retournes[i], ivr_naomit$Nb.Blocs.Retournes[i]))
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
228 (ivr_val_qu_$blocs.retournes.fr.[i] <- (ivr_naomit$Nb.Blocs.Retournes[i] / bm) * 100)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
229 (ivr_val_qu_$blocs.non.retournes.fr.[i] <- (ivr_naomit$Nb.Blocs.Non.Retournes[i] / bm) * 100)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
230 }
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
231
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
232 rm(bm, i)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
233
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
234
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
235 ivr_val_qu_$blocs.non.retournes.fr. <- ifelse(is.nan(ivr_val_qu_$blocs.non.retournes.fr.), NA, ivr_val_qu_$blocs.non.retournes.fr.)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
236 ivr_val_qu_$blocs.retournes.fr. <- ifelse(is.nan(ivr_val_qu_$blocs.retournes.fr.), NA, ivr_val_qu_$blocs.retournes.fr.)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
237
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
238
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
239 # ivr for loop by quadrat.
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
240 for (i in 1:seq_len(nrow(ivr_val_qu_))) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
241 if (ivr_val_qu_$Nb.Blocs.Non.Retournes[i] == 0 && ivr_val_qu_$Nb.Blocs.Retournes[i] == 0) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
242 ivr_ <- NA
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
243 }else {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
244 if (ivr_val_qu_$blocs.retournes.fr.[i] < 5) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
245 ivr_ <- 0
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
246 } else if (ivr_val_qu_$blocs.retournes.fr.[i] >= 5 && ivr_val_qu_$blocs.retournes.fr.[i] < 25) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
247 ivr_ <- 1
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
248 } else if (ivr_val_qu_$blocs.retournes.fr.[i] >= 25 && ivr_val_qu_$blocs.retournes.fr.[i] < 45) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
249 ivr_ <- 2
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
250 } else if (ivr_val_qu_$blocs.retournes.fr.[i] >= 45 && ivr_val_qu_$blocs.retournes.fr.[i] < 65) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
251 ivr_ <- 3
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
252 } else if (ivr_val_qu_$blocs.retournes.fr.[i] >= 65 && ivr_val_qu_$blocs.retournes.fr.[i] < 85) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
253 ivr_ <- 4
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
254 } else {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
255 ivr_ <- 5
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
256 }
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
257
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
258 ivr_val_qu_$valeur.ivr_quadrat[i] <- ivr_
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
259 }
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
260 }
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
261
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
262 rm(i, ivr_)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
263
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
264 # reorder variables for logical purpose
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
265 ivr_val_qu_ <- ivr_val_qu_[, c(1:56, 58, 57, 59)]
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
266 indic_full <- ivr_val_qu_
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
267 saveRDS(ivr_val_qu_, "ivr_val_qu.RDS")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
268 rm(ivr_naomit)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
269
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
270
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
271 ## Calculate ivr statistics now
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
272 ivr_val_qu_stat_ <- ivr_val_qu_ %>% dplyr::group_by(id.ivr, Site, Site_bis, Year, Month, Day) %>% dplyr::summarize(ivr_moy = mean(valeur.ivr_quadrat), ivr_et = sd(valeur.ivr_quadrat), ivr_med = median(valeur.ivr_quadrat), ivr_min = min(valeur.ivr_quadrat), ivr_max = max(valeur.ivr_quadrat), fr.r.moy = mean(blocs.retournes.fr.), fr.r.et = sd(blocs.retournes.fr.), fr.r.med = median(blocs.retournes.fr.), fr.r.min = min(blocs.retournes.fr.), fr.r.max = max(blocs.retournes.fr.), fr.nr.moy = mean(blocs.non.retournes.fr.), fr.nr.et = sd(blocs.non.retournes.fr.), fr.nr.med = median(blocs.non.retournes.fr.), fr.nr.min = min(blocs.non.retournes.fr.), fr.nr.max = max(blocs.non.retournes.fr.), nb. = dplyr::n())
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
273
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
274 Date <- as.Date(paste0(ivr_val_qu_stat_$Year, "-", ivr_val_qu_stat_$Month, "-", ivr_val_qu_stat_$Day), origin = "1970-01-01")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
275 ivr_val_qu_stat_ <- tibble::add_column(ivr_val_qu_stat_, Date, .after = "Site_bis")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
276 rm(Date)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
277
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
278 ivr_val_qu_stat_ <- as.data.frame(ivr_val_qu_stat_)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
279 indic <- ivr_val_qu_stat_
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
280
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
281
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
282 #############################################################
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
283 # #
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
284 # Plot the IVR per site #
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
285 # #
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
286 #############################################################
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
287
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
288 ## plot ivr (NB: Year, Month, Day variable names are replace by Annee, Mois, Jour, cfr previous label use in the script)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
289 ivr_val_qu_stat_ <- dplyr::rename(ivr_val_qu_stat_, Annee = Year)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
290 ivr_val_qu_stat_ <- dplyr::rename(ivr_val_qu_stat_, Mois = Month)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
291 ivr_val_qu_stat_ <- dplyr::rename(ivr_val_qu_stat_, Jour = Day)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
292
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
293
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
294 # new IVR scale with continuous 0 to 5 environmental status levels based on % of overturned boulders /20, plus other site data
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
295
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
296 for (i in c(1:length(unique(ivr_val_qu_stat_$Site)))) {
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
297
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
298 ivr_val_eg <- dplyr::filter(ivr_val_qu_stat_, ivr_val_qu_stat_$Site == unique(ivr_val_qu_stat_$Site)[i])
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
299
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
300 ivr_plot <- ggplot2::ggplot() +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
301 ggplot2::geom_point(ggplot2::aes(x = ivr_val_qu_stat_$Date, y = ivr_val_qu_stat_$fr.r.moy / 20), col = "grey") +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
302 ggplot2::geom_rect(ggplot2::aes(xmin = min(ivr_val_qu_stat_$Date), xmax = max(ivr_val_qu_stat_$Date), ymin = - 0.5, ymax = 5 / 20, fill = "#FF0000"), alpha = 0.3) +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
303 ggplot2::geom_rect(ggplot2::aes(xmin = min(ivr_val_qu_stat_$Date), xmax = max(ivr_val_qu_stat_$Date), ymin = 5 / 20, ymax = 25 / 20, fill = "#F59404"), alpha = 0.3) +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
304 ggplot2::geom_rect(ggplot2::aes(xmin = min(ivr_val_qu_stat_$Date), xmax = max(ivr_val_qu_stat_$Date), ymin = 25 / 20, ymax = 45 / 20, fill = "#FAFA15"), alpha = 0.3) +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
305 ggplot2::geom_rect(ggplot2::aes(xmin = min(ivr_val_qu_stat_$Date), xmax = max(ivr_val_qu_stat_$Date), ymin = 45 / 20, ymax = 65 / 20, fill = "#18E125"), alpha = 0.3) +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
306 ggplot2::geom_rect(ggplot2::aes(xmin = min(ivr_val_qu_stat_$Date), xmax = max(ivr_val_qu_stat_$Date), ymin = 65 / 20, ymax = 85 / 20, fill = "#04F5F5"), alpha = 0.3) +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
307 ggplot2::geom_rect(ggplot2::aes(xmin = min(ivr_val_qu_stat_$Date), xmax = max(ivr_val_qu_stat_$Date), ymin = 85 / 20, ymax = 5.5, fill = "#1A1AE8"), alpha = 0.3) +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
308 ggplot2::scale_fill_manual(values = c("#F59404", "#FAFA15", "#FF0000", "#04F5F5", "#18E125", "#1A1AE8")) +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
309 ggplot2::geom_pointrange(ggplot2::aes(x = ivr_val_eg$Date, y = ivr_val_eg$fr.r.moy / 20, ymin = ivr_val_eg$fr.r.moy / 20 - ivr_val_eg$fr.r.et / 20, ymax = ivr_val_eg$fr.r.moy / 20 + ivr_val_eg$fr.r.et / 20), col = "black") +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
310 ggplot2::xlab("Date") +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
311 ggplot2::ylab("IVR") +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
312 ggplot2::ggtitle(unique(ivr_val_eg$Site_bis)) +
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
313 ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, vjust = 0.5, hjust = 1), legend.position = "none")
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
314
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
315 ggplot2::ggsave(paste0("ivr_", unique(ivr_val_eg$Site), ".png"), ivr_plot, height = 3, width = 3.5)
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
316
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
317
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
318 }
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
319
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
320 report <- args[3]
8c6142630659 planemo upload for repository https://github.com/Marie59/champ_blocs commit 8b6fcddd239979c11977472de6cbb349690758c8
ecology
parents:
diff changeset
321 loop_file <- source(args[4])