DOI: 10.6084/m9.figshare.14404868.v1
title: R code, data, and analysis documentation for Colour biases in learned foraging preferences in Trinidadian guppies

description: <b>Summary</b><br>---------------This is the repository containing the R code and data to produce the analyses and figures in the manuscript ‘Colour biases in learned foraging preferences in Trinidadian guppies’. R version 3.6.2 was used for this project. <br>Here, we explain how to reproduce the results, provides the location of the metadata for the data sheets, and gives descriptions of the root directory contents and folder contents. This material is adapted from the README file of the project, `README.md` which is located in the root directory.<br><b>How to reproduce the results</b>-------------------------------------------This project uses the `renv` package from RStudio to manage package dependencies and ensure reproducibility through time. To ensure results are reproduced based on the versions of the packages used at the time this project was created, you will need to install `renv` using `install.packages("renv")` in R.<br>If you want to reproduce the results it is best to download the entire repository onto your system. This can be done by clicking the Download button on the FigShare repository (DOI: 10.6084/m9.figshare.14404868). This will download a zip file of the entire repository. Unzip the zip file to get access to the project files.<br>Once the repository is downloaded onto your system, navigate to the root directory and open `guppy-colour-learning-project.Rproj`. It is important to open the project using the `.Rproj` file to ensure the working directory is set correctly. Then install the package dependencies onto your system using `renv::restore()`. <br>Running `renv::restore()` will install the correct versions of all the packages needed to reproduce our results. Packages are installed in a stand-alone library for this project and will not affect your installed R packages anywhere else.<br>If you want to reproduce specific results from the analyses you can open either `analysis-experiment-1.Rmd` for results from experiment 1 or `analysis-experiment-2.Rmd` for results from experiment 2. Both are located in the root directory. You can select the Run All option under the Code option in the navbar of RStudio to execute all the code chunks. You can also run all chunks independently as well though we advise that you do so sequentially since variables necessary for the analysis are created as the script progresses.<br><b>Metadata</b>--------------Data are available in the `<b>data/</b>` directory. <br>- `colour-learning-experiment-1-data.csv` are the data for experiment 1- `colour-learning-experiment-2-full-data.csv` are the data for experiment 2<br>We provide the variable descriptions for the data sets in the file `metadata.md` located in the `<b>data/</b>` directory. The packages required to conduct the analyses and construct the website as well as their versions and citations are provided in the file `required-r-packages.md`.<br><b>Directory structure</b>---------------------------- - `<b>data/</b>` contains the raw data used to conduct the analyses - `<b>docs/</b>` contains the reader-friendly html write-up of the analyses, the GitHub pages site is built from this folder - `<b>R/</b>` contains custom R functions used in the analysis - `<b>references/</b>` contains reference information and formatting for citations used in the project - `<b>renv/</b>` contains an activation script and configuration files for the renv package manager - `<b>figs/</b>` contains the individual files for the figures and residual diagnostic plots produced by the analysis scripts. This directory is created and populated by running `analysis-experiment-1.Rmd`, `analysis-experiment-2.Rmd` and `combined-figures.Rmd`<br><b>Root directory contents</b>------------------------------------The root directory contains Rmd scripts used to conduct the analyses, create figures, and render the website pages. Below we describe the contents of these files as well as the additional files contained in the root directory.<br> - `analysis-experiment-1.Rmd` is the R code and documentation for the experiment 1 data preparation and analysis. This script generates the Analysis 1 page of the website.<br> - `analysis-experiment-2.Rmd` is the R code and documentation for the experiment 2 data preparation and analysis. This script generates the Analysis 2 page of the website.<br> - `protocols.Rmd` contains the protocols used to conduct the experiments and generate the data. This script generates the Protocols page of the website.<br> - `index.Rmd` creates the Homepage of the project site.<br> - `combined-figures.Rmd` is the R code used to create figures that combine data from experiments 1 and 2. Not used in the project site.<br> - `treatment-object-side-assignment.Rmd` is the R code used to assign treatments and object sides during trials for experiment 2. Not used in the project site.<br> - `renv.lock` is a JSON formatted plain text file which contains package information for the project. renv will install the packages listed in this file upon executing `renv::restore()`<br> - `required-r-packages.md` is a plain text file containing the versions and sources of the packages required for the project.<br> - `styles.css` contains the CSS formatting for the rendered html pages<br> - `LICENSE.md` contains the license indicating the conditions upon which the code can be reused<br> - `guppy-colour-learning-project.Rproj` is the R project file which sets the working directory of the R instance to the root directory of this repository. If trying to run the code in this repository to reproduce results it is important to open R by clicking on this `.Rproj` file.<br>