# Zoo Free Recall
Analysis scripts for the main manuscript results section and figures. (Note: Values related to permutation scripts reported in this component will vary from the manuscript, as noted below. Please see component 1 for values used in manuscript analysis)
## Setup
1. Download the entire Rproject folder from the OSF at [link](link)
2. Install necessary versions of r packages (manually or via
`renv::restore()`)
## Install Packages
This project uses the *renv* package to manage package versions. All
necessary information regarding packages used anywhere within this
project are saved in the `renv.lock` file. For more information about
the *renv* package, check out
<https://rstudio.github.io/renv/articles/renv.html>.
To install all of the proper package versions, run the following code.
**Be sure to have the Rproject open in RStudio prior to running this
code**. It will automatically download and install the needed R
packages. It will also functionally separate this R project from your
other projects (you won’t have access to other packages already
installed on your machine while still in this project).
``` r
renv::restore()
```
If using *renv* is not desirable, you can also manually install the
necessary packages using the following code:
``` r
install.packages(c("tidyverse","DT","here","psych","rstatix","jtools","xlsx"))
```
## Usage
Once the project has been downloaded and the r packages installed,
running the following code can be used to recreate the cleaned data and
the results section of the manuscript:
**Note** - Running the cleaning script can take a little while (about
10-15 minutes). Since it randomly permutes the subjects’ responses,
there will be small numerical discrepancies between any analyses using
the permuted distributions and the published manuscript. The pattern of
results and statistical significance of all results should remain
consistent. There is a `set.seed(7272)` function used to ensure
computational reproducibility, but that does not always ensure exactly
identical results.
``` r
# load the data and clean it
source(here("scripts","clean_and_save_data.R"))
# rerun the results script and save it into the reports folder
rmarkdown::render(
here::here("script files",
"manuscript_results.Rmd"),
output_file = "manuscript_results",
output_dir = here::here("reports"),
)
```
## Understanding the Layout of this Project
This R-project has four main subdirectories: `/data`, `/reports`,
`/figures`, and `/script files`.
### `/data`
- All subject IDs for the data in this archive have been randomized to
add a further layer of anonymity
- `/data_manuscript`
- `data_manuscript_no-mulitple-locations.xlsx` - This is the full
data.
- `data_manuscript_no-mulitple-locations_cleaned.rds` is the result
of running the `clean_and_save_data.R` script. It will retain the
proper data formats and structures for all analyses and graphs
which use this data.
### `/reports`
- This folder holds all reports which were generated within this
project. The only report included is the one created by the
`manuscript_results.Rmd` script.
- `manuscript_results.html`
- This HTML file contains the code and results from the results
section of the published manuscript. The serial position analyses
and the post-hoc partial correlation analyses are not included but
can be found at with the osf project at [LINK](!link) and
[LINK](!link)
### `script files`
- `clean_and_save.R`
- This script scrapes the `/data` directory (and it’s subdirectories)
for all `.xlsx` files, imports them into R, cleans them, generates
the permutations (for context, forward, and backward adjacency
scores), computes the absolute lag differences, and percent rank of
the first recall location. This script all saves each cleaned result
as an `.rds` file in the same directory as the original .xlsx file
with a suffix of “\_cleaned” appended just before the file
extension.
- `generate_manuscript_figure_1.R`
- This script recreates the following `\figures` folder:
- `figure_1_300dpi.jpg`
- Figure 1 that appears in manuscript
- `figure_1_4-5_300dpi.jpg`
- faceted version of Figure 1 highlighting 4-5-year-old
permutation
- `figure_1_6-7_300dpi.jpg`
- faceted version of Figure 1 highlighting 6-7-year-old
permutation
- `figure_1_8-10_300dpi.jpg`
- faceted version of Figure 1 highlighting 8-10-year-old
permutation
- `figure_2_alternate_300ppi.jpg`
- alternate (unused) version of figure 2
- `generate_manuscript_figure_2.R`
- This script recreates the following `\figures` folder:
- `figure_2a_error_bars_300dpi.jpg`
- `figure_2a_without_error_bars_300dpi.jpg`
- `figure_2b_error_bars_300dpi.jpg`
- `figure_2b_without_error_bars_300dpi.jpg`
- `helper_functions.R`
- This file holds all of the functions used by this project (e.g.,
functions used to create permutations, or compute context scores, or
generate reports)
- `manuscript_results.Rmd`
- This script runs the main analyses within the manuscript. The output
is an HTML file which can be viewed in any web browser. It has a
clickable table of contents to bring users quickly to particular
sections of the results. There are also buttons which can show/hide
the code used for each section of the results.
- `randomize_subject_ids.R`
- This script checks the project for any `.xlsx` files and randomizes
the subject IDs within each age group. This script is **NOT**
intended to be run by users. It was included to show the process
used to randomize subject IDS prior to the data being posted online.
## Acknowledgments
- README.md template from
<https://gist.github.com/PurpleBooth/109311bb0361f32d87a2>