library(ggplot2)    # Création de graphiques
library(sf)         # Travailler avec des données spatiales
library(tidysdm)    # Outils pour la modélisation de distribution spatiale
library(terra)      # Manipulation de données raster
library(tidyterra)  # Fonctions utilitaires pour terra
library(stacks)     # Création de modèles empilés
library(DALEX)
library(psych) # pairs.panels
library(ggpubr) #ggarrange
library(gridExtra)#corrplot l'un à côté de l'autre
library(corrplot)
library(spatstat)
library(patchwork)
library(corrr)#network_plot
library(randomForest) # Random Forest
library(readxl)
df <- read_sf("CN_ObsOFFH_Aff.shp")
# Nidification :
StackVE <- rast("C:/Users/ECOFIRST-LOUISE/Documents/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/VE_JFG_Stack_v3.tif")
StackVE <- StackVE[[!names(StackVE) %in% c("TPI_250", "Sealed_250", "Barbeau", "Ombre","CLC")]]
names(StackVE)
plot(StackVE[[c(names(StackVE)[1:9])]])
plot(StackVE[[c(names(StackVE)[10:18])]])
df2 <- df %>%
bind_cols(terra::extract(StackVE, df, ID = FALSE)) #4,117 données
glimpse(df2)
#str(df2)
df3 <- df2 %>% st_drop_geometry() %>%
dplyr::select(c(22:(length(df2)-1))) %>%
mutate(across(everything(), as.numeric))
#str(df3)
cor_spear <- cor(df3, use = "pairwise.complete.obs", method = "spearman")
png(
filename = "C:/Users/ECOFIRST-LOUISE/Documents/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/plot/CN/CN_Chasse_corr.png",
width = 11,
height = 9,
units = "in",
res = 300
)
corrplot(
cor_spear,
method = "color",       # colored boxes
tl.cex = 0.8,
type = "lower",
addCoef.col = "black",  # show correlation coefficients in black
number.cex = 0.6        # adjust coefficient font size
)
dev.off()
cor_spear <- cor(df3, use = "pairwise.complete.obs", method = "spearman")
corrplot(
cor_spear,
method = "color",       # colored boxes
tl.cex = 0.8,
type = "lower",
addCoef.col = "black",  # show correlation coefficients in black
number.cex = 0.6        # adjust coefficient font size
)
spearman_plot <- recordPlot()
df4 <- df3 %>%
dplyr::select(-c("Dist_Foret2022","Linéaires_ligneux_Density")) # Retrait des variables corrélées (|rho|>0.6)
#
df4 <- df4 %>%
mutate(across(everything(),~ as.numeric(scale(.))))%>% na.omit()
synthetic_data <- df4
for(i in seq_along(synthetic_data)) {
synthetic_data[[i]] <- sample(synthetic_data[[i]])
}
combined_data <- rbind(df4, synthetic_data)
labels <- factor(c(rep(1, nrow(df4)), rep(0, nrow(synthetic_data))))
set.seed(126)
rf_model <- randomForest(x=combined_data, y=labels, importance=TRUE, ntree=2000)
print(rf_model)
saveRDS(rf_model, "~/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/RDS_files/CN_Chasse_rf_model.rds")
rf_model <- readRDS("~/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/RDS_files/CN_Chasse_rf_model.rds")
print(rf_model)
png(
filename = "C:/Users/ECOFIRST-LOUISE/Documents/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/plot/CN/CN_chass_OOB.png",
width = 8,
height = 6,
units = "in",
res = 300
)
plot(
rf_model,
col = c("black", "red", "green"),
lwd = 2,
main = "Erreur OOB Random Forest - CN territoire/Chasse"
)
legend(
"topright",
legend = c("OOB globale", "0", "1"),
col = c("black", "red", "green"),
lwd = 2
)
dev.off()
plot(
rf_model,
col = c("black", "red", "green"),
lwd = 2,
main = "Erreur OOB Random Forest - CN territoire/Chasse"
)
legend(
"topright",
legend = c("OOB globale", "0", "1"),
col = c("black", "red", "green"),
lwd = 2
)
#set.seed(126)
rf_model <- randomForest(x=combined_data, y=labels, importance=TRUE, ntree=500)
knitr::opts_chunk$set(echo = TRUE)
library(raster)
library(dplyr)
library(lubridate)
library(tidyverse)  # Bibliothèque principale pour la manipulation de données
library(ggplot2)    # Création de graphiques
library(sf)         # Travailler avec des données spatiales
library(tidysdm)    # Outils pour la modélisation de distribution spatiale
library(terra)      # Manipulation de données raster
library(tidyterra)  # Fonctions utilitaires pour terra
library(stacks)     # Création de modèles empilés
library(DALEX)
library(psych) # pairs.panels
library(ggpubr) #ggarrange
library(gridExtra)#corrplot l'un à côté de l'autre
library(corrplot)
library(spatstat)
library(patchwork)
library(corrr)#network_plot
library(randomForest) # Random Forest
library(readxl)
df <- read_sf("CN_ObsOFFH_Aff.shp")
# Nidification :
StackVE <- rast("C:/Users/ECOFIRST-LOUISE/Documents/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/VE_JFG_Stack_v3.tif")
StackVE <- StackVE[[!names(StackVE) %in% c("TPI_250", "Sealed_250", "Barbeau", "Ombre","CLC")]]
names(StackVE)
plot(StackVE[[c(names(StackVE)[1:9])]])
plot(StackVE[[c(names(StackVE)[10:18])]])
df2 <- df %>%
bind_cols(terra::extract(StackVE, df, ID = FALSE)) #4,117 données
glimpse(df2)
#str(df2)
df3 <- df2 %>% st_drop_geometry() %>%
dplyr::select(c(22:(length(df2)-1))) %>%
mutate(across(everything(), as.numeric))
#str(df3)
cor_spear <- cor(df3, use = "pairwise.complete.obs", method = "spearman")
png(
filename = "C:/Users/ECOFIRST-LOUISE/Documents/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/plot/CN/CN_Chasse_corr.png",
width = 11,
height = 9,
units = "in",
res = 300
)
corrplot(
cor_spear,
method = "color",       # colored boxes
tl.cex = 0.8,
type = "lower",
addCoef.col = "black",  # show correlation coefficients in black
number.cex = 0.6        # adjust coefficient font size
)
dev.off()
cor_spear <- cor(df3, use = "pairwise.complete.obs", method = "spearman")
corrplot(
cor_spear,
method = "color",       # colored boxes
tl.cex = 0.8,
type = "lower",
addCoef.col = "black",  # show correlation coefficients in black
number.cex = 0.6        # adjust coefficient font size
)
spearman_plot <- recordPlot()
df4 <- df3 %>%
dplyr::select(-c("Dist_Foret2022","Linéaires_ligneux_Density")) # Retrait des variables corrélées (|rho|>0.6)
df4 <- df4 %>%
mutate(across(everything(),~ as.numeric(scale(.))))%>% na.omit()
synthetic_data <- df4
for(i in seq_along(synthetic_data)) {
synthetic_data[[i]] <- sample(synthetic_data[[i]])
}
combined_data <- rbind(df4, synthetic_data)
labels <- factor(c(rep(1, nrow(df4)), rep(0, nrow(synthetic_data))))
rf_model <- randomForest(x=combined_data, y=labels, importance=TRUE, ntree=500)
print(rf_model)
saveRDS(rf_model, "~/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/RDS_files/CN_Chasse_rf_model.rds")
#saveRDS(rf_model, "~/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/RDS_files/CN_Chasse_rf_model.rds")
rf_model <- readRDS("~/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/RDS_files/CN_Chasse_rf_model.rds")
print(rf_model)
png(
filename = "C:/Users/ECOFIRST-LOUISE/Documents/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/plot/CN/CN_chass_OOB.png",
width = 8,
height = 6,
units = "in",
res = 300
)
plot(
rf_model,
col = c("black", "red", "green"),
lwd = 2,
main = "Erreur OOB Random Forest - CN territoire/Chasse"
)
legend(
"topright",
legend = c("OOB globale", "0", "1"),
col = c("black", "red", "green"),
lwd = 2
)
dev.off()
plot(
rf_model,
col = c("black", "red", "green"),
lwd = 2,
main = "Erreur OOB Random Forest - CN territoire/Chasse"
)
legend(
"topright",
legend = c("OOB globale", "0", "1"),
col = c("black", "red", "green"),
lwd = 2
)
importance_MDA <- importance(rf_model, type = 1) %>%
as.data.frame() %>%
tibble::rownames_to_column(var = "Variable")
importance_MDG <- importance(rf_model, type = 2) %>%
as.data.frame() %>%
tibble::rownames_to_column(var = "Variable")
Importance <- left_join(importance_MDA,importance_MDG, by="Variable")
print(Importance %>% arrange(desc(MeanDecreaseAccuracy), desc(MeanDecreaseGini)))
plot_MDA <- Importance %>%
arrange(MeanDecreaseAccuracy) %>%  # On trie du plus petit au plus grand pour coord_flip
mutate(Variable = factor(Variable, levels = Variable)) %>%
ggplot(aes(x = Variable, y = MeanDecreaseAccuracy)) +
geom_segment(aes(x = Variable, xend = Variable,
y = 0, yend = MeanDecreaseAccuracy),
color = "darkgrey", linewidth = 1) +
geom_point(color = "#1f78b4", size = 4, fill = scales::alpha("lightblue",0.5),shape=21, stroke=2) +
coord_flip() +
labs(title = "MDA",
x = "",
y = "Mean Decrease Accuracy") +
geom_text(aes(label=round(MeanDecreaseAccuracy,2)), hjust=-0.3, size=4) +
theme_minimal(base_size = 14)
plot_MDA
ggsave("C:/Users/ECOFIRST-LOUISE/Documents/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/plot/CN/CN_chass_MDA.png", plot_MDA, width = 13, height = 8, dpi = 300)
plot_MDG <- Importance %>%
arrange(MeanDecreaseGini) %>%
mutate(Variable = factor(Variable, levels = Variable)) %>%
ggplot(aes(x = Variable, y = MeanDecreaseGini)) +
geom_segment(aes(x = Variable, xend = Variable,
y = 0, yend = MeanDecreaseGini),
color = "darkgrey", linewidth = 1) +
geom_point(size=4, color="darkgreen",fill=scales::alpha("lightgreen", 0.5),shape=21, stroke=2) +
coord_flip() +
labs(title = "MDG",
x = "",
y = "Mean Decrease Gini") +
geom_text(aes(label=round(MeanDecreaseGini,2)), hjust=-0.3, size=4) +
theme_minimal(base_size = 14)
plot_MDG
ggsave("C:/Users/ECOFIRST-LOUISE/Documents/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/plot/CN/CN_chass_MDG.png", plot_MDG, width = 13, height = 8, dpi = 300)
# Affichage
Importance_plot <- plot_MDA|plot_MDG
Importance_plot <- Importance_plot +  plot_layout() +  # for shared legend
plot_annotation(  title = "Importance des variables RF",
subtitle = "Ciconia nigra Chasse"
)
Importance_plot
ggsave("C:/Users/ECOFIRST-LOUISE/Documents/2. PROJETS/1.Marche_SPW 2282_Lot 1_modélisation Cigogne noire et Milan Royal/plot/CN/CN_chass_Importance_plot.png", Importance_plot, width = 24, height = 10, dpi = 300)
shiny::runApp('2. PROJETS/2.Marché SPW 2282 - Lot 2_Référentiel d'activités chiroptères/ShinyApp/ZIP/AppV3/App')
setwd("~/2. PROJETS/2.Marché SPW 2282 - Lot 2_Référentiel d'activités chiroptères/ShinyApp/ZIP/AppV3/App")
shiny::runApp()
library(readxl)
library(writexl)
library(ggplot2)
library(viridis)
library(pROC)
library(PRROC)
library(sf)
library(tidyr)
library(pbapply)
library(psych)
library(formatR)
library(ggpubr)
library(data.table)
library(gridExtra)
library(grid)
library(dplyr)
library(lubridate)
knitr::opts_chunk$set( warning = FALSE, message = FALSE, cache = FALSE, fig.asp = 1)
knitr::opts_chunk$set(tidy.opts = list(width.cutoff = 60), tidy = TRUE)
f1 <- list.files( path = "~/2. PROJETS/2.Marché SPW 2282 - Lot 2_Référentiel d'activités chiroptères/Data/Data_Plecotus",pattern = "\\.csv$", full.names = TRUE, recursive = F)
f2 <- list.files( path = "~/2. PROJETS/2.Marché SPW 2282 - Lot 2_Référentiel d'activités chiroptères/Data",pattern = "\\.csv$", full.names = TRUE, recursive = F) #Fichier DEMNA 2024
f3 <- list.files( path = "~/2. PROJETS/2.Marché SPW 2282 - Lot 2_Référentiel d'activités chiroptères/Data/Data_BE_2023",pattern = "\\.csv$", full.names = TRUE, recursive = F)
f <- c(f1,f2,f3)
basename(f)
#Nombre de données dans tous mes fichiers
total_rows <- sum(sapply(f, function(file) {
nrow(fread(file, na.strings = "", dec = ".", encoding = "Latin-1", fill = TRUE))
}))
DB_plec_list <- pblapply(f, function(file) {
dl <- fread(file, na.strings = "", dec = ".", encoding = "Latin-1", fill = TRUE)
names(dl) <- make.unique(names(dl))
dl <- as_tibble(dl, .name_repair = "unique") #lecture des fichiers csv en format data.table
# Ajout du nom du fichier source
dl <- as_tibble(dl) # Convertir en tibble pour une manipulation plus rapide
dl <- dl %>% mutate(across(everything(), as.character)) # Convertir toutes les colonnes en caractères pour éviter les problèmes dans coalesce
dl <- dl %>% mutate(across(where(is.character), ~ gsub('"', "'", .)))
# Standardisation des noms de colonnes. coalece prend la première valeur non-NA dans l'ordre des colonnes spécifiées (généralement 1 type de colonne par csv)
dl <- dl %>%
mutate(
Commentaires = safe_coalesce(dl, c("commentaire", "rem", "Rem", "Remarque", "Commentaires", "Remarques", "commentaires", "Commentaire", "NB")),
Id_avant_validation = safe_coalesce(dl, c("Id_avant_validation", "Id.avant.validation", "Id_avantvalidation","Id_avant validation", "Id_avant.validation", "Id_avant.validation..partim.","Id_avant validation (partim)","Id-avant validation","Id_avant_v")),
Habitat3 = safe_coalesce(dl, c("Habitat3", "habitat3", "Habitat.3", "H3")),
Group = safe_coalesce(dl, c("Group", "Groupe")),
Species = safe_coalesce(dl, c("Species", "Espece")),
NbCalls = safe_coalesce(dl, c("NbCris", "NbCalls")),
Ics = safe_coalesce(dl, c("Isc", "Ics")),
X = safe_coalesce(dl, c("X", "X1")),
Y = safe_coalesce(dl, c("Y", "Y1")),
Year = safe_coalesce(dl, c("Year", "Annee")),
Month = safe_coalesce(dl, c("Month", "Mois")),
Day = safe_coalesce(dl, c("Day", "Jour")),
Hour = safe_coalesce(dl, c("Hour", "Heure")),
Minute = safe_coalesce(dl, c("Minute", "Min","Minut")),
Id = safe_coalesce(dl, c("Id", "ID", "id")),
Night_Date = safe_coalesce(dl, c("Night_Date", "Date_nuit")),
Machine = safe_coalesce(dl, c("Machine","Recorder","Type")),
Opérateur = safe_coalesce(dl, c("Opérateur", "opérateur")),
Clé_formulaire = safe_coalesce(dl, c("Clé_formulaire", "cle_formulaire")),
Fichier = safe_coalesce(dl, c("File", "Fichier","File2", "File_2", "Code.validation")),
Nuit.complète = safe_coalesce(dl, c("Nuit.complète", "nuit.complète")),
Dossier = safe_coalesce(dl, c("Dossier", "Directory")),
Validation = safe_coalesce(dl, c("Validation"))
) %>%
select(any_of(c("Id", "Id_avant_validation", "Validation", "Group", "IGp", "Species", "ISp",
"Year", "Month", "Day", "Hour", "Minute", "Machine", "Night_Date", "NbCalls", "Iqual",
"Opérateur", "Site", "X", "Y", "Projet", "Fichier", "Commentaires"
)))
dl <- dl %>%
mutate(across(where(is.character), ~ na_if(.x, "NA")))
dl$Hour <- as.numeric(dl$Hour)
dl$Minute <- as.numeric(dl$Minute)
dl$Day <- as.numeric(dl$Day)
dl$Month <- as.numeric(dl$Month)
dl$Year <- as.numeric(dl$Year)
# Create a Date variable based on year month day
if (all(c("Year", "Month", "Day") %in% names(dl))) {
dl$Date <- as.Date(paste(dl$Year, dl$Month, dl$Day, sep = "-"), format = "%Y-%m-%d")
} else {
dl$Date <- NA
}
#Create DateTime variable
dl$DateTime <- as.POSIXct(paste(dl$Year, dl$Month, dl$Day, dl$Hour, dl$Minute), format = "%Y %m %d %H %M", tz = "UTC")
dl$Night_Date <- parse_date_time(dl$Night_Date,
orders = c("Ymd", "dmY", "mdY", "dmy", "ymd", "Y-m-d", "d-m-Y", "m/d/Y", "d/m/Y","Y/m/d", "Y-m-d", "d-m-Y", "m-d-Y", "d-m-y","Y-m-d"),
exact = FALSE) #Homogénéisation des formats de date
dl$Night_Date <- as.Date(dl$Night_Date)
# Delete duplicate
dl <- dl %>% distinct()
dl$Source <- basename(file)
return(dl)
})
# Combine and deduplicate
DB_plec <- data.table::rbindlist(DB_plec_list, fill = TRUE, use.names = TRUE) %>%
distinct(across(!c(Source, Opérateur)), .keep_all = TRUE) #Vérification des doublons en ignorant la source et l'opérateur (Q. Smits sur un fichier et QS dans un autre se rapportant à la même date, heure, minute, espèce, ...)
# Efficiently compute Night_Date only where missing
na_idx <- which(is.na(DB_plec$Night_Date))
# Fill missing Night_Date using DateTime and Hour
DB_plec$Night_Date[na_idx] <- as.Date(DB_plec$DateTime[na_idx])
DB_plec$Night_Date[na_idx] <- ifelse(DB_plec$Hour[na_idx] <= 12,  DB_plec$Night_Date[na_idx] - 1, DB_plec$Night_Date[na_idx])
#Nombre de données totales
nrow(DB_plec)
DB_plec
runApp()
knitr::opts_chunk$set(echo = TRUE)
library(data.table)
library(ggplot2)
library(dplyr)
library(sf)
#Correction des noms des espèces
Sp <- read.csv( "~/2. PROJETS/2.Marché SPW 2282 - Lot 2_Référentiel d'activités chiroptères/ShinyApp/Référentiel/DB_refV2.csv")
Sp
DB_V4
DB <- read_sf("Data/Data_output/DB_cleaned_v8.gpkg") #Espèces
#DB <- read_sf("Data/Data_output/DB_cleaned_grpV2.gpkg") #Groupe
nrow(DB)
DB$Species <- as.factor(DB$Species)
table(DB$Species)
str(DB)
head(DB)
DB$Machine <- as.factor(DB$Machine)
DB$Month <- as.numeric(DB$Month)
#Change month number into character
DB$Month <- factor(DB$Month, levels = 2:12, labels = c("Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"))
#Mi_site <- read_sf("Data/Data_output/FID_Cat_milieu.shp") %>% st_drop_geometry()
Mi_site <- read_sf("Data/Data_output/FID_Cat_milieu_grp.shp") %>% st_drop_geometry()
str(Mi_site)
DB_site <- left_join(DB, Mi_site, by = "SiteXY")
str(DB_site)
df_milieu <- DB_site %>%
group_by(Cat_mil) %>%
summarise(count = n(),
n_nuits = n_distinct(Night_Date))
df_milieu
df_milieu <- DB_site %>%
group_by(Cat_mil) %>%
summarise(count = n(),
n_nuits = n_distinct(Night_Date)) %>%
ungroup() %>% filter(!is.na(Cat_mil))
#Graphique
GG_milieu1 <- ggplot(df_milieu, aes(x = reorder(Cat_mil, -count), y = count)) +
geom_bar(stat = "identity", fill = "steelblue") +
labs(title = "Nombre de données par catégorie de milieu", x = "Catégorie de milieu", y = "Nombre de données") +theme_minimal()+theme(axis.text.x = element_text(angle = 45, hjust = 1))
GG_milieu1
GG_milieu2 <- ggplot(df_milieu, aes(x = reorder(Cat_mil, -n_nuits), y = n_nuits)) +
geom_bar(stat = "identity", fill = "steelblue") +
labs(title = "Nombre de nuits complètes par catégorie de milieu", x = "Catégorie de milieu", y = "Nombre de nuits complètes") +theme_minimal()+theme(axis.text.x = element_text(angle = 45, hjust = 1))
GG_milieu2
recorder <- read.csv2("Tentative_jointure_SM-Lieu.csv", fileEncoding = "latin1") %>% dplyr::select(Type, Recorder)
colnames(recorder) <- c("Type", "Machine")
str(recorder)
DB_V2 <- left_join(DB_site,recorder, by = "Machine")
DB_V2 <- DB_V2 %>%
mutate(Machine = ifelse(!(is.na(Type)),Type,Machine),
Machine = ifelse(Machine == "PNS-CHIRO", "Smminibat", Machine),
Machine= ifelse(grepl("SM2", Machine), "SM2", Machine),
Machine= ifelse(grepl("S2", Machine), "SM2", Machine),
Machine = ifelse(grepl("SM3", Machine), "SM3", Machine),
Machine=ifelse(grepl("SM4", Machine), "SM4", Machine),
Machine=ifelse(grepl("S4", Machine), "SM4", Machine),
Machine=ifelse(grepl("SMU", Machine), "Smminibat", Machine),
Machine = ifelse(grepl("LIFEVAR",Machine),"Smminibat", Machine),
Machine = ifelse(grepl("SM-MINI",Machine), "Smminibat", Machine),
Machine = ifelse(grepl("SMMbat",Machine),"Smminibat", Machine),
Machine = ifelse(is.na(Machine),"Non renseigné", Machine),
Machine = ifelse(!(Machine %in% c("SM2", "SM3", "SM4", "Smminibat", "Non renseigné")), "Other", Machine))
DB_V2$Machine <- as.factor(DB_V2$Machine)
df_machine <- DB_V2 %>%
group_by(Machine) %>%
summarise(count = n(),
n_nuits = n_distinct(Night_Date)) %>%
ungroup()
df_machine
GG1 <- ggplot(df_machine, aes(x = reorder(Machine, -count), y = count)) +
geom_bar(stat = "identity", fill = "steelblue") +
labs(title = "Nombre de données par machine", x = "Machine", y = "Nombre de données") +theme_minimal()
GG1
#save as PNG
#ggsave("output/Figures/Nombre_de_données_par_machine.png", plot = GG1, width = 10, height = 6, dpi = 300)
Nuit_tot <- df_machine %>%
summarise(total_nuits = sum(n_nuits)) %>%
pull(total_nuits)
GG2 <- ggplot(df_machine, aes(x = reorder(Machine, -n_nuits), y = n_nuits)) +
geom_bar(stat = "identity", fill = "steelblue") +
labs(title = "Nombre de nuits complètes par machine", x = "Machine", y = "Nombre de nuits complètes", subtitle = paste("Nombre de nuits total :",Nuit_tot)) +theme_minimal()
GG2
#save as PNG
#ggsave("output/Figures/Nombre_de_nuits_par_machine.png", plot = GG2, width = 10, height = 6, dpi = 300)
DB_V2 <- DB_V2 %>% filter(Machine%in%c("SM2", "SM3", "SM4", "Smminibat"))
nrow(DB_V2)
DB_V3 <- DB_V2 %>%
mutate(Period = case_when(
Month %in% c("Avril", "Mai", "Juin", "Juillet") ~ "Envol des jeunes",
Month %in% c("Août", "Septembre", "Octobre") ~ "Swarming",
TRUE ~ "Hors période"
)) %>%
filter(Period != "Hors période")
DB_V3$Period <- as.factor(DB_V3$Period)
nrow(DB_V3)
str(DB_V3)
runApp()
species
runApp()
runApp()
runApp()
species <- species[!species %in% c("Pipistrelle de Kulh", "Barbastelle d'Europe","Sérotine de Nilsson","Grande noctule","Murin des marais","Pipistrelle pygmée","Sérotine bicolore", "Oreillard gris","Oreillard roux")]
species
species <- species[!species %in% c("Pipistrelle de Kulh", "Barbastelle d'Europe","Sérotine de Nilsson","Grande noctule","Murin des marais","Pipistrelle pygmée","Sérotine bicolore", "Oreillard gris","Oreillard roux")]
species
species <- sort(taxons[!grepl("sp\\.$", taxons)])
species
species <- species[!species %in% c("Pipistrelle de Kuhl", "Barbastelle d'Europe","Sérotine de Nilsson","Grande noctule","Murin des marais","Pipistrelle pygmée","Sérotine bicolore", "Oreillard gris","Oreillard roux")]
species
species <- species[!species %in% c("Pipistrelle de Kuhl", "Barbastelle d'Europe","Sérotine de Nilsson","Grande noctule","Murin des marais","Pipistrelle pygmée","Sérotine bicolore", "Oreillard gris","Oreillard roux","Murin de Bechstein","Murin d'Alcathoé","Murin à oreilles échancrées","Murin à moustaches","Murin de Brandt")]
species
runApp()
species
runApp()
DB_ref$Esp.Groupe
runApp()
runApp()
runApp()
runApp()
shiny::runApp()
groups  <- sort(taxons[ grepl("sp\\.$", taxons)]|taxons[grepl("NoID"),taxons])
groups  <- sort(taxons[ grepl("sp\\.$", taxons)]|taxons[grepl("NoID\\.$"),taxons])
groups  <- sort(taxons[ grepl("sp\\.$", taxons)])
groups
groups  <- v(sort(taxons[ grepl("sp\\.$", taxons)]), "NoID Chiro")
groups  <- c(sort(taxons[ grepl("sp\\.$", taxons)]), "NoID Chiro")
groups
runApp()
species <- c(sort(taxons[!grepl("sp\\.$", taxons)]),-"NoID Chiro")
species <- c(sort(taxons[!grepl("sp\\.$", taxons)]),!"NoID Chiro")
species <- setdiff(taxons, groups)
species
runApp()
runApp()
shiny::runApp('~/2. PROJETS/2.Marché SPW 2282 - Lot 2_Référentiel d'activités chiroptères/ShinyApp/AppV6/App')
shiny::runApp('~/2. PROJETS/2.Marché SPW 2282 - Lot 2_Référentiel d'activités chiroptères/ShinyApp/AppV6/App')
shiny::runApp()
install.packages("shinyjs")
