---
title: "01 - Animal Data"
author: "Randi L. Garcia"
date: "September 11, 2024"
output: html_document
---

#Data Analysis

Loading data.

```{r, message=FALSE, warning=FALSE}
library(tidyverse)
library(readr)

animals <- read_csv("https://randilgarcia.github.io/sds290spring24/data/animals.csv")
```

Cleaning the data

```{r, message=FALSE, warning=FALSE}
animals <- animals %>%
  mutate(pID = seq.int(1, nrow(animals))) %>%
  select(pID, order, animal, 
         cute_calm, scary_calm, 
         cute_happy, scary_happy, 
         cute_nerv, scary_nerv, 
         cute_scared, scary_scared) %>%
  mutate_at(vars(cute_calm:scary_scared), as.numeric) %>%
  slice(3:length(animals))
```

Another way to think of the data

```{r}
animals_long <- animals %>%
  gather(var, value, cute_calm:scary_scared) %>%
  separate(var, c("cue", "emotion"), sep = "_") %>%
  spread(emotion, value) 
```

Visualizing the variance

```{r}
#how do we visualize variability?
qplot(x = calm, data = animals_long, bins = 5)
```

```{r}
#looking at variability by condition
ggplot(animals_long, aes(x = animal, fill = cue, y = calm)) +
  geom_boxplot()
```
