Cargando paquete requerido: ggpp
Registered S3 methods overwritten by 'ggpp':
method from
heightDetails.titleGrob ggplot2
widthDetails.titleGrob ggplot2
Adjuntando el paquete: 'ggpp'
The following object is masked from 'package:ggplot2':
annotate
Adjuntando el paquete: 'ggpubr'
The following objects are masked from 'package:ggpp':
as_npc, as_npcx, as_npcy
The following object is masked from 'package:egg':
ggarrange
#library(explore)#explore(dat_clean)descriptiva_clean=dat_clean %>%group_by(group) %>%get_summary_stats(type ="common") %>% dplyr::filter(variable=="Value")dclass1=descriptiva_clean%>%select(-variable,-iqr,-mean,-sd,-se,-ci)library(dplyr)library(magrittr) # Para el operador %>%
Adjuntando el paquete: 'magrittr'
The following object is masked from 'package:purrr':
set_names
The following object is masked from 'package:tidyr':
extract
library(seewave)
Adjuntando el paquete: 'seewave'
The following object is masked from 'package:lubridate':
duration
The following object is masked from 'package:readr':
spec
# Calcular la media en dB por grupodescriptiva_clean2 <- dat_clean %>%group_by(group) %>%mutate(mean_dB =meandB(Value), sd_dB=sddB(Value, level="SPL"),sd_lineal=sd(Value_linear)) # Calcular la media en dB usando seewave::meandB()summary_table <- descriptiva_clean2 %>%group_by(group) %>%summarise(mean_dB =mean(mean_dB),mean_sd_dB =mean(sd_dB),mean_sd_lineal =mean(sd_lineal)) # Calcular el promedio de mean_dB por grupo# Mostrar la tabla resumend2=summary_table %>%select(mean_dB, mean_sd_dB)Tabla_D=cbind(dclass1,d2)%>%rename(Talla="group",Mínimo="min",Máximo="max",Mediana="median",Media="mean_dB", sd="mean_sd_dB")%>%mutate_if(is.numeric, ~round(., 2))Tabla_D
library(dplyr)library(magrittr) # Para el operador %>%library(seewave)# Calcular la media en dB por grupodescriptiva_clean4 <- dat_clean %>%group_by(group, Banda) %>%mutate(mean_dB =meandB(Value), sd_dB=sddB(Value, level="SPL"),sd_lineal=sd(Value_linear)) # Calcular la media en dB usando summary_table4 <- descriptiva_clean4 %>%group_by(group, Banda) %>%summarise(mean_dB =mean(mean_dB),mean_sd_dB =mean(sd_dB),mean_sd_lineal =mean(sd_lineal)) # Calcular el promedio de mean_dB por grupo
`summarise()` has grouped output by 'group'. You can override using the
`.groups` argument.
# Mostrar la tabla resumend4=summary_table4 %>%select(mean_dB, mean_sd_dB)
ggsave(filename ="FM_modas_LM.png",plot = firmas_group_LM, height =6, # Specifies the height of the plot in incheswidth =12, # Specifies the width of the plot in inchesdpi =1000, # Specifies the resolution in dots per inchpath ="F:/Tesis abordo/Tesis abordo/Figuras/Objetivo01/",device ="png")
w=ggplot(dat_clean,alpha=0.5)+#geom_line(alpha=0.1, aes(color=group),lwd=1, show.legend = T)+geom_smooth(aes(y = Value, x=as.numeric(Frequency),color=group),size=1.5,method ="lm", show.legend = T, alpha=0.5)+scale_y_continuous(limits =c(-65,-45))+#stat_regline_equation()+theme_presentation(base_size =16.5) +xlab("Frecuencia (kHz)") +ylab("Sv (dB)")+scale_x_continuous(breaks =c(38,70,90,120,170,200,260))+geom_vline(xintercept =c(38,45,90,170,260),linetype =c("dashed"),color="gray")+geom_hline(yintercept =c(-70,-60,-50,-40),linetype =c("dashed"),color="gray")+scale_color_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))+theme(legend.title=element_blank())+theme(panel.grid.major.y =element_line(color ="gray", linetype ="dashed"))+theme(panel.grid.major.x =element_line(color ="gray", linetype ="dashed"))k=ggplot(dat_clean)+#geom_line(alpha=0.1, aes(color=group),lwd=1, show.legend = T)+geom_smooth(aes(y = Value, x=as.numeric(Frequency),color=group),size=1.5,method ="gam", show.legend = F)+#stat_regline_equation()+theme_presentation(base_size =16.5) +xlab("Frecuencia (kHz)") +ylab("Sv (dB)")+scale_y_continuous(limits =c(-65,-45))+scale_x_continuous(breaks =c(38,70,90,120,170,200,260))+geom_vline(xintercept =c(38,45,90,170,260),linetype =c("dashed"),color="gray")+geom_hline(yintercept =c(-70,-60,-50,-40),linetype =c("dashed"),color="gray")+scale_color_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))+theme(legend.title=element_blank())+theme(panel.grid.major.y =element_line(color ="gray", linetype ="dashed"))+theme(panel.grid.major.x =element_line(color ="gray", linetype ="dashed"))library(cowplot)# Crear las gráficas w y k (código que proporcionaste)# Obtener la leyenda de una de las gráficas (por ejemplo, w)legend_w <-get_legend(w)# Combinar las dos gráficas y agregar la leyendacombined_plot <-plot_grid( k +theme(legend.position ="none"), # Ocultar la leyenda de la gráfica w w +theme(legend.position ="none"), # Ocultar la leyenda de la gráfica k legend_w,ncol =3, rel_heights =c(1, 1, 1),rel_widths =c(1,1,0.35), # Ajustar las alturas relativaslabels =c("(a)", "(b)", ""), # Etiquetas de enumeraciónalign ="h"# Alinear horizontalmente las partes)# Ajustar el tamaño de la leyendacombined_plot <- combined_plot +theme(legend.text =element_text(size =19), # Tamaño del texto de la leyendalegend.title =element_text(size =14) # Tamaño del título de la leyenda)# Imprimir la figura combinadaprint(combined_plot)
ggsave(filename ="Resumen_firmas_modales3.png",plot = firmas_tallas, height =5, # Specifies the height of the plot in incheswidth =12, # Specifies the width of the plot in inchesdpi =1000, # Specifies the resolution in dots per inchpath ="F:/Tesis abordo/Tesis abordo/Figuras/Objetivo01/",device ="png")
ggsave(filename ="6.FM_modas_espectral.png",plot = firmas_group, height =10, # Specifies the height of the plot in incheswidth =10, # Specifies the width of the plot in inchesdpi =1000, # Specifies the resolution in dots per inchpath ="F:/Tesis abordo/Tesis abordo/Figuras/Objetivo01/",device ="png")
sS_dftlong.mean = dat_mean2 %>%group_by(group) %>%mutate(#you can't use m=0 in order to calculate k0 onlysmoothed_k0tok1 = emuR::dct(track_value,m=1,fit=T),smoothed_k0tok2 = emuR::dct(track_value,m=2,fit=T),smoothed_k0tok3 = emuR::dct(track_value,m=3,fit=T),smoothed_k0tok4 = emuR::dct(track_value,m=4,fit=T),smoothed_k0tok5 = emuR::dct(track_value,m=5,fit=T),smoothed_k0tok6 = emuR::dct(track_value,m=6,fit=T))
ggplot(sS_dftlong.mean) +geom_line(size=2,aes(x =as.numeric(Frequency), y =10*log10(smoothed_k0tok1), color = group) ) +#geom_rect(data = bloqueos, aes(xmin = xmin, xmax = xmax, ymin = -Inf, ymax = Inf), fill = "gray", alpha = 0.75) + # Ajusta color y transparencia según necesiteslabs(x ="Frecuencia", y ="10*log10(Value)") +scale_color_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))+scale_fill_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))
#############ggplot(sS_dftlong.mean) +geom_line(size=2,aes(x =as.numeric(Frequency), y =10*log10(smoothed_k0tok2), color = group) ) +#geom_rect(data = bloqueos, aes(xmin = xmin, xmax = xmax, ymin = -Inf, ymax = Inf), fill = "gray", alpha = 0.75) + # Ajusta color y transparencia según necesiteslabs(x ="Frecuencia", y ="10*log10(Value)") +scale_color_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))+scale_fill_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))
#############ggplot(sS_dftlong.mean) +geom_line(size=2,aes(x =as.numeric(Frequency), y =10*log10(smoothed_k0tok3), color = group) ) +#geom_rect(data = bloqueos, aes(xmin = xmin, xmax = xmax, ymin = -Inf, ymax = Inf), fill = "gray", alpha = 0.75) + # Ajusta color y transparencia según necesiteslabs(x ="Frecuencia", y ="10*log10(Value)") +scale_color_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))+scale_fill_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))
#############ggplot(sS_dftlong.mean) +geom_line(size=2,aes(x =as.numeric(Frequency), y =10*log10(smoothed_k0tok4), color = group) ) +#geom_rect(data = bloqueos, aes(xmin = xmin, xmax = xmax, ymin = -Inf, ymax = Inf), fill = "gray", alpha = 0.75) + # Ajusta color y transparencia según necesiteslabs(x ="Frecuencia", y ="10*log10(Value)") +scale_color_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))+scale_fill_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))
Warning in FUN(X[[i]], ...): Se han producido NaNs
#############ggplot(sS_dftlong.mean) +geom_line(size=2,aes(x =as.numeric(Frequency), y =10*log10(smoothed_k0tok5), color = group) ) +#geom_rect(data = bloqueos, aes(xmin = xmin, xmax = xmax, ymin = -Inf, ymax = Inf), fill = "gray", alpha = 0.75) + # Ajusta color y transparencia según necesiteslabs(x ="Frecuencia", y ="10*log10(Value)") +scale_color_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))+scale_fill_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))
#############ggplot(sS_dftlong.mean) +geom_line(size=2,aes(x =as.numeric(Frequency), y =10*log10(smoothed_k0tok6), color = group) ) +#geom_rect(data = bloqueos, aes(xmin = xmin, xmax = xmax, ymin = -Inf, ymax = Inf), fill = "gray", alpha = 0.75) + # Ajusta color y transparencia según necesiteslabs(x ="Frecuencia", y ="10*log10(Value)") +scale_color_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))+scale_fill_manual(name="Longitud (cm)",values =c("#5f5f5f","#0000ff","#000080","#00bf00","#ffff00","#ff8000","#ff00bf","#ff0000","#a6533c"))
ggsave(filename ="Kolmo_Sv_modas.png",plot = Figura03, height =4, # Specifies the height of the plot in incheswidth =8, # Specifies the width of the plot in inchesdpi =1000, # Specifies the resolution in dots per inchpath ="F:/Tesis abordo/Tesis abordo/Figuras/Objetivo01/",device ="png")
#library(coin)#oneway_test(Value ~ Class, data = dat_clean)
# Realizar la prueba K-S para todas las combinaciones de grupos# Asegúrate de que dat_clean esté definido correctamente# dat_clean <- ...# Asegúrate de que dat_clean esté definido correctamente# dat_clean <- ...# Crear un data frame para almacenar los resultadosresults <-data.frame(group1 =character(),group2 =character(),D_value =numeric(),p_value =numeric(),stringsAsFactors =FALSE)# Obtener grupos únicosgroups <-unique(dat_clean$group)# Realizar la prueba K-S para todas las combinaciones de gruposfor (i in1:(length(groups) -1)) {for (j in (i +1):length(groups)) { group1 <- groups[i] group2 <- groups[j]# Subconjuntos de datos para los dos grupos data_group1 <- dat_clean$Value[dat_clean$group == group1] data_group2 <- dat_clean$Value[dat_clean$group == group2]# Realizar la prueba K-S test_result <-ks.test(data_group1, data_group2)# Almacenar resultados en el data frame results results <-rbind(results, data.frame(group1 = group1,group2 = group2,D_value =round(test_result$statistic, 2),p_value =round(test_result$p.value, 2) )) }}# Mostrar el resultado final con las modificaciones requeridasprint(results)
ggsave(filename ="kw_total_sv_ob1.png",plot = kw_total, height =9, # Specifies the height of the plot in incheswidth =6, # Specifies the width of the plot in inchesdpi =1000, # Specifies the resolution in dots per inchpath ="F:/Tesis abordo/Tesis abordo/Figuras/Objetivo01/",device ="png")
ggsave(filename ="kw_total_sv_bandas_ob1.png",plot = kw_total_sv_bandas, height =8, # Specifies the height of the plot in incheswidth =12, # Specifies the width of the plot in inchesdpi =1000, # Specifies the resolution in dots per inchpath ="F:/Tesis abordo/Tesis abordo/Figuras/Objetivo01/",device ="png")