Code
# options to customize chunk outputs
::opts_chunk$set(
knitrtidy.opts = list(width.cutoff = 65),
tidy = TRUE,
message = FALSE
)
A very fancy project
# print link to github repo if any
if (file.exists("./.git/config")){
<- readLines("./.git/config")
config <- grep("url", config, value = TRUE)
url <- gsub("\\turl = |.git$", "", url)
url cat("\nSource code and data found at [", url, "](", url, ")", sep = "")
}
# options to customize chunk outputs
::opts_chunk$set(
knitrtidy.opts = list(width.cutoff = 65),
tidy = TRUE,
message = FALSE
)
The first goal of this report
The second goal of this report
You can have the sections listed here, for instance:
flowchart A[Read data] --> B(Format data) B --> C(Graphs) C --> D(Statistical analysis) D --> E(Model summary) style A fill:#44015466 style B fill:#3E4A894D style C fill:#26828E4D style D fill:#6DCD594D
# knitr is require for creating html/pdf/word reports formatR is
# used for soft-wrapping code
# install/ load packages
::load_packages(packages = c("knitr", "formatR", "lmerTest",
sketchy"warbleR", "ggplot2", "Rraven"))
<- imp_raven(path = "/media/m/KINGSTON/anotaciones/", warbler.format = TRUE,
ref all.data = TRUE, name.from.file = TRUE, ext.case = "lower")
$rango.frec <- ref$top.freq - ref$bottom.freq
ref
<- table(ref$sound.files)
tab
<- ref[order(ref$sound.files, ref$start), ]
ref
<- warbleR::info_sound_files(path = "/media/m/KINGSTON/Canto/wavs")
sfi
$cuenta <- sapply(sfi$sound.files, function(x) sum(ref$sound.files ==
sfi
x))
$tasa.prom <- sfi$cuenta/sfi$duration * 60
sfi
$tasa.sd <- sapply(sfi$sound.files, function(x) {
sfi
<- ref[ref$sound.files == x, ]
Y
<- sapply(1:(nrow(Y) - 1), function(y) {
tasas
<- sfi$duration[sfi$sound.files == x] - Y$start[y]
dur
nrow(Y) - y)/dur * 60
(
})
sd(tasas)
})
$frec.pico.prom <- sapply(sfi$sound.files, function(x) {
sfimean(ref$`Peak Freq (Hz)`[ref$sound.files == x])
})
$frec.pico.sd <- sapply(sfi$sound.files, function(x) {
sfisd(ref$`Peak Freq (Hz)`[ref$sound.files == x])
})
$duracion.prom <- sapply(sfi$sound.files, function(x) {
sfimean(ref$`Delta Time (s)`[ref$sound.files == x])
})
$duracion.sd <- sapply(sfi$sound.files, function(x) {
sfisd(ref$`Delta Time (s)`[ref$sound.files == x])
})
$entropia.prom <- sapply(sfi$sound.files, function(x) {
sfimean(ref$`Avg Entropy (bits)`[ref$sound.files == x])
})
$entropia.sd <- sapply(sfi$sound.files, function(x) {
sfimean(ref$`Avg Entropy (bits)`[ref$sound.files == x])
})
$rango.prom <- sapply(sfi$sound.files, function(x) {
sfimean(ref$rango.frec[ref$sound.files == x])
})
$rango.sd <- sapply(sfi$sound.files, function(x) {
sfimean(ref$rango.frec[ref$sound.files == x])
})
$tratamiento <- gsub(".wav", "", sfi$sound.files)
sfi
<- stack(sfi[, c("tasa.prom", "duracion.prom", "entropia.prom",
stk_sfi "frec.pico.prom", "rango.prom")])
$tratamiento <- c("Alta", "Baja", "Diluyente", "Control negativo",
stk_sfi"Media")
$tratamiento <- factor(stk_sfi$tratamiento, levels = c("Control negativo",
stk_sfi"Diluyente", "Baja", "Media", "Alta"))
<- stack(sfi[, c("tasa.sd", "duracion.sd", "entropia.sd",
stk_sfi_sd "frec.pico.sd", "rango.sd")])
<- c(tasa.prom = "Tasa de estridulación", duracion.prom = "Duración",
etiq entropia.prom = "Entropía", frec.pico.prom = "Frecuencia pico",
rango.prom = "Rango de frecuencia")
$sd <- stk_sfi_sd$values
stk_sfi
# graficar duracion vs tratamiento con barras de error
ggplot(stk_sfi, aes(x = tratamiento, y = values, color = ind)) + geom_point(size = 3) +
geom_errorbar(aes(ymin = values - sd, ymax = values + sd), width = 0.01) +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) + scale_color_viridis_d() +
theme_classic() + facet_wrap(~ind, scales = "free_y", labeller = labeller(ind = etiq)) +
labs(x = "Concentración", y = "Valor") + theme(legend.position = "none") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1))
$tratamiento <- gsub(".wav", "", ref$sound.files)
ref
$tratamiento[ref$tratamiento == "Control(Etanol)"] <- "Diluyente"
ref$tratamiento[ref$tratamiento == "Control(NADA)"] <- "Control negativo"
ref
$tratamiento <- factor(ref$tratamiento, levels = c("Control negativo",
ref"Diluyente", "Baja", "Media", "Alta"))
<- lmerTest::lmer(`Peak Freq (Hz)` ~ tratamiento + (1 | tratamiento),
pk_mod data = ref)
Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
eigenvalue close to zero: 2.6e-09
summary(pk_mod)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: `Peak Freq (Hz)` ~ tratamiento + (1 | tratamiento)
Data: ref
REML criterion at convergence: 3430.7
Scaled residuals:
Min 1Q Median 3Q Max
-6.490 -0.147 -0.010 0.127 8.349
Random effects:
Groups Name Variance Std.Dev.
tratamiento (Intercept) 61807 249
Residual 465524 682
Number of obs: 220, groups: tratamiento, 5
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 4694 254 215 18.46 <2e-16 ***
tratamientoDiluyente -141 378 215 -0.37 0.710
tratamientoBaja -266 392 215 -0.68 0.498
tratamientoMedia -998 439 215 -2.27 0.024 *
tratamientoAlta -1272 493 215 -2.58 0.010 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correlation of Fixed Effects:
(Intr) trtmnD trtmnB trtmnM
trtmntDlynt -0.672
tratamintBj -0.648 0.436
tratamintMd -0.579 0.389 0.375
tratamntAlt -0.516 0.347 0.334 0.299
<- lmerTest::lmer(`Delta Time (s)` ~ tratamiento + (1 | tratamiento),
dur_mod data = ref)
Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
eigenvalue close to zero: 4.2e-09
summary(dur_mod)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: `Delta Time (s)` ~ tratamiento + (1 | tratamiento)
Data: ref
REML criterion at convergence: -95.9
Scaled residuals:
Min 1Q Median 3Q Max
-1.443 -0.352 -0.046 0.172 12.047
Random effects:
Groups Name Variance Std.Dev.
tratamiento (Intercept) 0.00851 0.0923
Residual 0.03503 0.1872
Number of obs: 220, groups: tratamiento, 5
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 0.2542 0.0934 215.0000 2.72 0.007 **
tratamientoDiluyente 0.0408 0.1360 215.0000 0.30 0.764
tratamientoBaja 0.1822 0.1389 215.0000 1.31 0.191
tratamientoMedia 0.1205 0.1491 215.0000 0.81 0.420
tratamientoAlta -0.0201 0.1612 215.0000 -0.12 0.901
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correlation of Fixed Effects:
(Intr) trtmnD trtmnB trtmnM
trtmntDlynt -0.687
tratamintBj -0.672 0.462
tratamintMd -0.626 0.430 0.421
tratamntAlt -0.579 0.398 0.390 0.363
<- lmerTest::lmer(`Avg Entropy (bits)` ~ tratamiento + (1 |
entr_mod data = ref)
tratamiento),
summary(entr_mod)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: `Avg Entropy (bits)` ~ tratamiento + (1 | tratamiento)
Data: ref
REML criterion at convergence: 277.9
Scaled residuals:
Min 1Q Median 3Q Max
-7.905 -0.510 0.097 0.647 3.809
Random effects:
Groups Name Variance Std.Dev.
tratamiento (Intercept) 0.0509 0.226
Residual 0.1992 0.446
Number of obs: 220, groups: tratamiento, 5
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 3.75e+00 2.28e-01 1.35e-09 16.44 1
tratamientoDiluyente -2.24e-01 3.32e-01 1.50e-09 -0.67 1
tratamientoBaja 8.18e-01 3.39e-01 1.63e-09 2.42 1
tratamientoMedia 3.23e-01 3.63e-01 2.14e-09 0.89 1
tratamientoAlta 5.76e-01 3.91e-01 2.89e-09 1.47 1
Correlation of Fixed Effects:
(Intr) trtmnD trtmnB trtmnM
trtmntDlynt -0.688
tratamintBj -0.674 0.464
tratamintMd -0.630 0.433 0.424
tratamntAlt -0.584 0.402 0.394 0.368
<- lmerTest::lmer(rango.frec ~ tratamiento + (1 | tratamiento),
rango_mod data = ref)
Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
unable to evaluate scaled gradient
Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Hessian is numerically singular: parameters are not uniquely determined
Warning: Model failed to converge with 1 negative eigenvalue: -1.2e-07
summary(rango_mod)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: rango.frec ~ tratamiento + (1 | tratamiento)
Data: ref
REML criterion at convergence: 1432.7
Scaled residuals:
Min 1Q Median 3Q Max
-1.2659 -0.6624 -0.2861 0.0582 2.4710
Random effects:
Groups Name Variance Std.Dev.
tratamiento (Intercept) 0.707 0.841
Residual 42.865 6.547
Number of obs: 220, groups: tratamiento, 5
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 8.991 0.984 215.000 9.14 <2e-16 ***
tratamientoDiluyente -1.717 1.790 215.000 -0.96 0.34
tratamientoBaja 1.487 2.049 215.000 0.73 0.47
tratamientoMedia -1.638 2.793 215.000 -0.59 0.56
tratamientoAlta -2.192 3.520 215.000 -0.62 0.53
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correlation of Fixed Effects:
(Intr) trtmnD trtmnB trtmnM
trtmntDlynt -0.550
tratamintBj -0.480 0.264
tratamintMd -0.352 0.194 0.169
tratamntAlt -0.280 0.154 0.134 0.098
optimizer (nloptwrap) convergence code: 0 (OK)
unable to evaluate scaled gradient
Hessian is numerically singular: parameters are not uniquely determined
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in felis ut mauris consectetur sodales. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=es_CR.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=es_CR.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=es_CR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_CR.UTF-8 LC_IDENTIFICATION=C
time zone: America/Costa_Rica
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Rraven_1.0.13 ggplot2_3.5.1 warbleR_1.1.32 NatureSounds_1.0.4
[5] seewave_2.2.3 tuneR_1.4.7 lmerTest_3.1-3 lme4_1.1-35.5
[9] Matrix_1.7-0 formatR_1.14 knitr_1.49
loaded via a namespace (and not attached):
[1] gtable_0.3.6 rjson_0.2.23 xfun_0.49
[4] htmlwidgets_1.6.4 remotes_2.5.0 lattice_0.22-6
[7] numDeriv_2016.8-1.1 vctrs_0.6.5 tools_4.4.1
[10] bitops_1.0-9 generics_0.1.3 parallel_4.4.1
[13] tibble_3.2.1 proxy_0.4-27 fansi_1.0.6
[16] pkgconfig_2.0.3 lifecycle_1.0.4 compiler_4.4.1
[19] farver_2.1.2 stringr_1.5.1 brio_1.1.5
[22] munsell_0.5.1 sketchy_1.0.3 htmltools_0.5.8.1
[25] RCurl_1.98-1.16 yaml_2.3.10 pillar_1.9.0
[28] nloptr_2.1.1 crayon_1.5.3 MASS_7.3-61
[31] boot_1.3-30 nlme_3.1-165 tidyselect_1.2.1
[34] packrat_0.9.2 digest_0.6.37 stringi_1.8.4
[37] dplyr_1.1.4 labeling_0.4.3 splines_4.4.1
[40] fastmap_1.2.0 grid_4.4.1 colorspace_2.1-1
[43] cli_3.6.3 magrittr_2.0.3 utf8_1.2.4
[46] withr_3.0.2 scales_1.3.0 rmarkdown_2.28
[49] signal_1.8-1 pbapply_1.7-2 evaluate_1.0.1
[52] dtw_1.23-1 fftw_1.0-9 testthat_3.2.1.1
[55] viridisLite_0.4.2 rlang_1.1.4 Rcpp_1.0.13-1
[58] glue_1.8.0 xaringanExtra_0.8.0 rstudioapi_0.16.0
[61] minqa_1.2.7 jsonlite_1.8.9 R6_2.5.1