Last updated: 2023-08-21

Checks: 6 1

Knit directory: ms_mariposas_pheno/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has staged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20230601) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version e85e912. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  analysis/
    Untracked:  code/
    Untracked:  data/
    Untracked:  output/

Unstaged changes:
    Unmerged:   .Rprofile
    Unmerged:   .gitattributes
    Unmerged:   .gitignore
    Unmerged:   README.md
    Unmerged:   _workflowr.yml
    Unmerged:   ms_mariposas_pheno.Rproj

Staged changes:
    Deleted:    analysis/_site.yml
    Deleted:    analysis/about.Rmd
    Deleted:    analysis/analysis_peak.Rmd
    Deleted:    analysis/climate_sensibility.Rmd
    Deleted:    analysis/index.Rmd
    Deleted:    analysis/license.Rmd
    Deleted:    analysis/model_selection.Rmd
    Deleted:    analysis/plot_climate.Rmd
    Deleted:    analysis/prepare_climate.Rmd
    Deleted:    analysis/prepare_peak.Rmd
    Deleted:    analysis/prepare_transects_data.Rmd
    Deleted:    analysis/prepare_weigth_mean_date.Rmd
    Deleted:    code/README.md
    Deleted:    code/get_climate_transectos.R
    Deleted:    data/README.md
    Deleted:    data/best_models_prec.csv
    Deleted:    data/best_models_prec.xlsx
    Deleted:    data/best_models_temp.csv
    Deleted:    data/best_models_temp.xlsx
    Deleted:    data/doy_medio_sp.csv
    Deleted:    data/doy_medio_sp.xlsx
    Deleted:    data/doy_peak_sps.csv
    Deleted:    data/doy_peak_sps_WMD.csv
    Deleted:    data/models_prec.csv
    Deleted:    data/models_prec.xlsx
    Deleted:    data/models_prec_scaled.csv
    Deleted:    data/models_prec_scaled.xlsx
    Deleted:    data/models_prec_selected.xlsx
    Deleted:    data/models_tmed.csv
    Deleted:    data/models_tmed.xlsx
    Deleted:    data/models_tmed_scaled.csv
    Deleted:    data/models_tmed_scaled.xlsx
    Deleted:    data/models_tmed_selected.xlsx
    Deleted:    data/pheno.csv
    Deleted:    data/raw_data/Pheno_def.csv
    Deleted:    data/raw_data/Prueba_doy.xlsx
    Deleted:    data/raw_data/Tabla_variables_transectos_22.xls
    Deleted:    data/raw_data/climate_transects/climate_transect_all_avg.csv
    Deleted:    data/raw_data/climate_transects/prec_transect.csv
    Deleted:    data/raw_data/climate_transects/prec_transect_avg.csv
    Deleted:    data/raw_data/climate_transects/tmax_transect.csv
    Deleted:    data/raw_data/climate_transects/tmax_transect_avg.csv
    Deleted:    data/raw_data/climate_transects/tmed_transect.csv
    Deleted:    data/raw_data/climate_transects/tmed_transect_avg.csv
    Deleted:    data/raw_data/climate_transects/tmin_transect.csv
    Deleted:    data/raw_data/climate_transects/tmin_transect_avg.csv
    Deleted:    data/raw_data/pheno_sp/Aglais_urticae_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Anthocharis_cardamines_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Anthocharis_euphenoides_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Aporia_crataegi_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Arethusana_arethusa_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Argynnis_pandora_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Aricia_cramera_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Aricia_montensis_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Aricia_morronensis_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Brintesia_circe_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Cacyreus_marshalli_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Callophrys_rubi_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Carcharodus_baeticus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Celastrina_argiolus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Chazara_briseis_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Coenonympha_dorus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Coenonympha_pamphilus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Colias_alfacariensis_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Colias_crocea_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Colotis_evagore_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Cupido_lorquinii_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Cyaniris_semiargus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Erebia_hispania_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Euchloe_crameri_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Euphydryas_aurinia_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Fabriciana_adippe_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Fabriciana_niobe_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Favonius_quercus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Gegenes_nostrodamus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Glaucopsyche_melanops_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Gonepteryx_cleopatra_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Gonepteryx_rhamni_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Hesperia_comma_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Hipparchia_fidia_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Hipparchia_hermione_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Hipparchia_semele_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Hipparchia_statilinus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Hyponephele_lycaon_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Iphiclides_feisthamelii_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Issoria_lathonia_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Laeosopis_roboris_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Lampides_boeticus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Lasiommata_maera_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Lasiommata_megera_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Leptidea_sinapis_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Leptotes_pirithous_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Lycaena_alciphron_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Lycaena_phlaeas_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Lysandra_albicans_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Maniola_jurtina_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Melanargia_ines_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Melanargia_lachesis_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Melanargia_occitanica_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Melitaea_athalia_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Melitaea_deione_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Melitaea_didyma_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Melitaea_parthenoides_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Melitaea_phoebe_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Melitaea_trivia_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Muschampia_proto_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Nymphalis_polychloros_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Papilio_machaon_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pararge_aegeria_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Parnassius_apollo_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pieris_brassicae_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pieris_napi_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pieris_rapae_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Plebejus_argus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Plebejus_idas_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Polygonia_c-album_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Polyommatus_amandus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Polyommatus_escheri_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Polyommatus_golgus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Polyommatus_icarus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Polyommatus_nivescens_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Polyommatus_thersites_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pontia_daplidice_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pseudochazara_mercurius_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pseudophilotes_panoptes_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pyrgus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pyronia_bathseba_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pyronia_cecilia_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Pyronia_tithonus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Satyrium_esculi_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Satyrium_spini_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Satyrus_actaea_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Speyeria_aglaja_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Spialia_sertorius_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Thymelicus_sylvestris_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Tomares_ballus_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Vanessa_atalanta_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Vanessa_cardui_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Zerynthia_rumina_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp/Zizeeria_knysna_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp_novalid/Glaucopsyche_alexis_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/pheno_sp_novalid/Libythea_celtis_BMSSN_pheno.xlsx
    Deleted:    data/raw_data/prec_sn.rda
    Deleted:    data/raw_data/tmax_sn.rda
    Deleted:    data/raw_data/tmed_sn.rda
    Deleted:    data/raw_data/tmin_sn.rda
    Deleted:    data/raw_data/transectos_unidos_export.cpg
    Deleted:    data/raw_data/transectos_unidos_export.dbf
    Deleted:    data/raw_data/transectos_unidos_export.prj
    Deleted:    data/raw_data/transectos_unidos_export.shp
    Deleted:    data/raw_data/transectos_unidos_export.shx
    Deleted:    data/selected_species.csv
    Deleted:    data/transectos_climate.csv
    Deleted:    data/transectos_metadata.csv
    Deleted:    data/transectos_variables.csv
    Deleted:    data/trends_peak.csv
    Deleted:    data/trends_peak_nsites.csv
    Deleted:    output/README.md
    Deleted:    output/climate/plot_climate_sn.png
    Deleted:    output/climate/plot_prec_sn.png
    Deleted:    output/climate/plot_temp_sn.png
    Deleted:    output/pheno_peak_doy/Aglais urticae.pdf
    Deleted:    output/pheno_peak_doy/Anthocharis cardamines.pdf
    Deleted:    output/pheno_peak_doy/Anthocharis euphenoides.pdf
    Deleted:    output/pheno_peak_doy/Aporia crataegi.pdf
    Deleted:    output/pheno_peak_doy/Arethusana arethusa.pdf
    Deleted:    output/pheno_peak_doy/Argynnis pandora.pdf
    Deleted:    output/pheno_peak_doy/Aricia cramera.pdf
    Deleted:    output/pheno_peak_doy/Aricia montensis.pdf
    Deleted:    output/pheno_peak_doy/Aricia morronensis.pdf
    Deleted:    output/pheno_peak_doy/Brintesia circe.pdf
    Deleted:    output/pheno_peak_doy/Cacyreus marshalli.pdf
    Deleted:    output/pheno_peak_doy/Callophrys rubi.pdf
    Deleted:    output/pheno_peak_doy/Carcharodus baeticus.pdf
    Deleted:    output/pheno_peak_doy/Celastrina argiolus.pdf
    Deleted:    output/pheno_peak_doy/Chazara briseis.pdf
    Deleted:    output/pheno_peak_doy/Coenonympha dorus.pdf
    Deleted:    output/pheno_peak_doy/Coenonympha pamphilus.pdf
    Deleted:    output/pheno_peak_doy/Colias alfacariensis.pdf
    Deleted:    output/pheno_peak_doy/Colias crocea.pdf
    Deleted:    output/pheno_peak_doy/Colotis evagore.pdf
    Deleted:    output/pheno_peak_doy/Cupido lorquinii.pdf
    Deleted:    output/pheno_peak_doy/Cyaniris semiargus.pdf
    Deleted:    output/pheno_peak_doy/Erebia hispania.pdf
    Deleted:    output/pheno_peak_doy/Euchloe crameri.pdf
    Deleted:    output/pheno_peak_doy/Euphydryas aurinia.pdf
    Deleted:    output/pheno_peak_doy/Fabriciana adippe.pdf
    Deleted:    output/pheno_peak_doy/Fabriciana niobe.pdf
    Deleted:    output/pheno_peak_doy/Favonius quercus.pdf
    Deleted:    output/pheno_peak_doy/Gegenes nostrodamus.pdf
    Deleted:    output/pheno_peak_doy/Glaucopsyche melanops.pdf
    Deleted:    output/pheno_peak_doy/Gonepteryx cleopatra.pdf
    Deleted:    output/pheno_peak_doy/Gonepteryx rhamni.pdf
    Deleted:    output/pheno_peak_doy/Hesperia comma.pdf
    Deleted:    output/pheno_peak_doy/Hipparchia fidia.pdf
    Deleted:    output/pheno_peak_doy/Hipparchia hermione.pdf
    Deleted:    output/pheno_peak_doy/Hipparchia semele.pdf
    Deleted:    output/pheno_peak_doy/Hipparchia statilinus.pdf
    Deleted:    output/pheno_peak_doy/Hyponephele lycaon.pdf
    Deleted:    output/pheno_peak_doy/Iphiclides feisthamelii.pdf
    Deleted:    output/pheno_peak_doy/Issoria lathonia.pdf
    Deleted:    output/pheno_peak_doy/Laeosopis roboris.pdf
    Deleted:    output/pheno_peak_doy/Lampides boeticus.pdf
    Deleted:    output/pheno_peak_doy/Lasiommata maera.pdf
    Deleted:    output/pheno_peak_doy/Lasiommata megera.pdf
    Deleted:    output/pheno_peak_doy/Leptidea sinapis.pdf
    Deleted:    output/pheno_peak_doy/Leptotes pirithous.pdf
    Deleted:    output/pheno_peak_doy/Lycaena alciphron.pdf
    Deleted:    output/pheno_peak_doy/Lycaena phlaeas.pdf
    Deleted:    output/pheno_peak_doy/Lysandra albicans.pdf
    Deleted:    output/pheno_peak_doy/Maniola jurtina.pdf
    Deleted:    output/pheno_peak_doy/Melanargia ines.pdf
    Deleted:    output/pheno_peak_doy/Melanargia lachesis.pdf
    Deleted:    output/pheno_peak_doy/Melanargia occitanica.pdf
    Deleted:    output/pheno_peak_doy/Melitaea athalia.pdf
    Deleted:    output/pheno_peak_doy/Melitaea deione.pdf
    Deleted:    output/pheno_peak_doy/Melitaea didyma.pdf
    Deleted:    output/pheno_peak_doy/Melitaea parthenoides.pdf
    Deleted:    output/pheno_peak_doy/Melitaea phoebe.pdf
    Deleted:    output/pheno_peak_doy/Melitaea trivia.pdf
    Deleted:    output/pheno_peak_doy/Muschampia proto.pdf
    Deleted:    output/pheno_peak_doy/Nymphalis polychloros.pdf
    Deleted:    output/pheno_peak_doy/Papilio machaon.pdf
    Deleted:    output/pheno_peak_doy/Pararge aegeria.pdf
    Deleted:    output/pheno_peak_doy/Parnassius apollo.pdf
    Deleted:    output/pheno_peak_doy/Pieris brassicae.pdf
    Deleted:    output/pheno_peak_doy/Pieris napi.pdf
    Deleted:    output/pheno_peak_doy/Pieris rapae.pdf
    Deleted:    output/pheno_peak_doy/Plebejus argus.pdf
    Deleted:    output/pheno_peak_doy/Plebejus idas.pdf
    Deleted:    output/pheno_peak_doy/Polygonia c-album.pdf
    Deleted:    output/pheno_peak_doy/Polyommatus amandus.pdf
    Deleted:    output/pheno_peak_doy/Polyommatus escheri.pdf
    Deleted:    output/pheno_peak_doy/Polyommatus golgus.pdf
    Deleted:    output/pheno_peak_doy/Polyommatus icarus.pdf
    Deleted:    output/pheno_peak_doy/Polyommatus nivescens.pdf
    Deleted:    output/pheno_peak_doy/Polyommatus thersites.pdf
    Deleted:    output/pheno_peak_doy/Pontia daplidice.pdf
    Deleted:    output/pheno_peak_doy/Pseudochazara mercurius.pdf
    Deleted:    output/pheno_peak_doy/Pseudophilotes panoptes.pdf
    Deleted:    output/pheno_peak_doy/Pyrgus.pdf
    Deleted:    output/pheno_peak_doy/Pyronia bathseba.pdf
    Deleted:    output/pheno_peak_doy/Pyronia cecilia.pdf
    Deleted:    output/pheno_peak_doy/Pyronia tithonus.pdf
    Deleted:    output/pheno_peak_doy/Satyrium esculi.pdf
    Deleted:    output/pheno_peak_doy/Satyrium spini.pdf
    Deleted:    output/pheno_peak_doy/Satyrus actaea.pdf
    Deleted:    output/pheno_peak_doy/Speyeria aglaja.pdf
    Deleted:    output/pheno_peak_doy/Spialia sertorius.pdf
    Deleted:    output/pheno_peak_doy/Thymelicus sylvestris.pdf
    Deleted:    output/pheno_peak_doy/Tomares ballus.pdf
    Deleted:    output/pheno_peak_doy/Vanessa atalanta.pdf
    Deleted:    output/pheno_peak_doy/Vanessa cardui.pdf
    Deleted:    output/pheno_peak_doy/Zerynthia rumina.pdf
    Deleted:    output/pheno_peak_doy/Zizeeria knysna.pdf

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/prepare_weigth_mean_date.Rmd) and HTML (docs/prepare_weigth_mean_date.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
html 6239c1d ajpelu 2023-08-18 Build site.
Rmd 4e27e3a ajpelu 2023-08-18 wflow_publish("analysis/prepare_weigth_mean_date.Rmd")

library(tidyverse)
library(readxl)
library(janitor)
library(DT)
df_raw <- read_delim("data/raw_data/Pheno_def.csv", delim = ";") |> 
  janitor::clean_names() |> 
  mutate(valid_date = as.Date(date, format = "%d/%m/%y")) |> 
  mutate(doy = lubridate::yday(valid_date))
df_raw |> DT::datatable()
# Agrupa por sitio, fecha, specie y suma todos los contactos de un transecto (los tramos)
df <- df_raw |> 
  dplyr::select(valid_date, id_site, site, species, ntotal, doy, year) |> 
  group_by(species, valid_date, doy, id_site, site, year) |> 
  summarise(total_count = sum(ntotal))
df |> DT::datatable()
df_aux <- df |> 
  rowwise() |> # esto es para permitir operar a nivel de fila 
  mutate(doy_x_bichos = doy * total_count) # dia juliano * mariposas ese día 

df_aux |> DT::datatable()
df_pheno <- df_aux |> 
  group_by(species, site, id_site, year) |> # agrupar por sitio, especie y año 
  summarise(sum_doy_bichos = sum(doy_x_bichos), # Σ(día juliano x mariposas que se contabilizan ese día)
            sum_conteos = sum(total_count)) |>  # total de mariposas de la especie x que se han contabilizado este año:
  ungroup() |> 
  rowwise() |> 
  mutate(weigth_mean_date = round(sum_doy_bichos / sum_conteos, 0)) |> 
  separate(id_site, into = c("m", "site_id")) |> 
  dplyr::select(-m) |> 
  mutate(site_id = as.numeric(site_id))

df_pheno |> DT::datatable()
write_csv(df_pheno, here::here("data/doy_peak_sps_WMD.csv"))

sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] DT_0.26         janitor_2.1.0   readxl_1.4.2    lubridate_1.9.2
 [5] forcats_1.0.0   stringr_1.5.0   dplyr_1.1.0     purrr_1.0.1    
 [9] readr_2.1.4     tidyr_1.3.0     tibble_3.1.8    ggplot2_3.4.1  
[13] tidyverse_2.0.0 workflowr_1.7.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10       here_1.0.1        getPass_0.2-2     ps_1.7.1         
 [5] rprojroot_2.0.3   digest_0.6.31     utf8_1.2.2        R6_2.5.1         
 [9] cellranger_1.1.0  evaluate_0.19     httr_1.4.4        pillar_1.8.1     
[13] rlang_1.1.0       rstudioapi_0.14   whisker_0.4       callr_3.7.3      
[17] jquerylib_0.1.4   rmarkdown_2.19    htmlwidgets_1.6.2 bit_4.0.4        
[21] munsell_0.5.0     compiler_4.2.3    httpuv_1.6.8      xfun_0.39        
[25] pkgconfig_2.0.3   htmltools_0.5.4   tidyselect_1.2.0  fansi_1.0.3      
[29] crayon_1.5.2      tzdb_0.3.0        withr_2.5.0       later_1.3.0      
[33] grid_4.2.3        jsonlite_1.8.4    gtable_0.3.1      lifecycle_1.0.3  
[37] git2r_0.30.1      magrittr_2.0.3    scales_1.2.1      cli_3.6.0        
[41] stringi_1.7.8     vroom_1.6.3       cachem_1.0.6      fs_1.6.2         
[45] promises_1.2.0.1  snakecase_0.11.0  bslib_0.4.2       ellipsis_0.3.2   
[49] generics_0.1.3    vctrs_0.6.0       tools_4.2.3       bit64_4.0.5      
[53] glue_1.6.2        crosstalk_1.2.0   hms_1.1.2         parallel_4.2.3   
[57] processx_3.7.0    fastmap_1.1.0     yaml_2.3.7        timechange_0.1.1 
[61] colorspace_2.0-3  knitr_1.41        sass_0.4.5