data & packages

df = readRDS("ecd_obs_agathe.RDS") 
df <- df[!is.na(df$obs_ts),] 
df[is.na(df)] <- 0

espèce à considérer

espece<-c("num_Other_bony_fishes","num_Silky_shark","num_Common_dolphinfish")

transformation des variables

df$num_Other_bony_fishes=df$`num_Other bony fishes`
df$num_Common_dolphinfish=df$`num_Common dolphinfish`
df$num_Silky_shark=df$`num_Silky shark`

stratification

df$group = paste0("O",df$ocean,"G",df$code_assoc_groupe) 
# Création d'une variable groupe 
# O1G1, O1G2, O2G1, O2G2
# O1: Atlantique 02: Indien
# G1: Floating object G2: Free swiming school 
## Par océan et banc 
df1<-df[df$group =="O1G1",] 
# df1 contient tous les calais qui sont sont O1G1
df2<-df[df$group =="O1G2",]
# df2 contient tous les calais qui sont O1G2
df3<-df[df$group =="O2G1",]
# df3 contient tous les calais qui sont O2G1
df4<-df[df$group =="O2G2",]
# df4 contient tous les calais qui sont O2G2 
for (i in 1:length(espece)){
  
nom<-c("O1G1","O1G2","O2G1","O2G2")
data<-get(espece[i],df)
boxplot( data ~ df$group,
         main=gsub("^num_","",espece[i]),
         ylab="number of individuals",
         xlab="group",
         names = nom,
         outline=F)
}

for (i in 1:length(espece)){
  
nom<-c("O1G1","O1G2","O2G1","O2G2")
data<-get(espece[i],df)
boxplot( data ~ df$group,
         main=gsub("^num_","",espece[i]),
         ylab="number of individuals",
         xlab="group",
         names = nom,
         outline=T)
}