# Load package
library(tidyverse)
# Read the data into R
forensic <- read_csv(file = "data_forensic.csv")
Error: 'data_forensic.csv' does not exist in current working directory ('/Users/jadegurtala').
# Load the package
library(tidyverse)
## ── Attaching packages ──────────────────────────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.4 ✓ purrr 0.3.4
## ✓ tibble 3.1.2 ✓ dplyr 1.0.6
## ✓ tidyr 1.1.3 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.1
## ── Conflicts ─────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
# Load the swow data
swow <- read_tsv("data_swow.csv.zip")
## ! Multiple files in zip: reading ''swow.csv''
## ── Column specification ─────────────────────────────────────────────────────────────────────────────
## cols(
## cue = col_character(),
## response = col_character(),
## R1 = col_double(),
## N = col_double(),
## R1.Strength = col_double()
# Adding the "mystery" line
swow <- swow %>% mutate(id = 1:n()) # Adding the id column
# Rename the data
swow <- swow %>%
rename(
n_response = R1,
n_total = N,
strength = R1.Strength
)
## ! Multiple files in zip: reading ''swow.csv''
## ── Column specification ─────────────────────────────────────────────────────────────────────────────
## cols(
## cue = col_character(),
## response = col_character(),
## R1 = col_double(),
## N = col_double(),
## R1.Strength = col_double()
Forward associations with 'woman'
woman_fwd <- swow %>%
filter(cue == "woman", n_response > 1)
woman_bck <-swow %>%
filter(response == "woman", n_response > 1) %>%
Forward and backwards associations with 'man'
man_fwd <- swow %>%
filter(cue == "man", n_response >1)
man_bck <- swow %>%
filter(response == "man", n_response > 1) %>%
arrange(desc(strength))
Selecting variables & creating new variables
# Forward and backwards associates to the word "woman"
woman_fwd <- swow %>%
filter(cue == "woman", n_response > 1) %>%
select(cue, response, strength, id) %>%
mutate(
rank = rank(-strength), # rank the data by strength; the minus sign indicates descending order
type = "forward", # this is forward associate (i.e., it's woman_FWD)
word = "woman", # the word is "woman" (i.e., it's WOMAN_fwd)
associate = response # for forward associations, the RESPONSE is the associate
)
woman_bck <- swow %>%
filter(response == "woman", n_response > 1) %>%
arrange(desc(strength)) %>%
select(cue, response, strength, id) %>%
mutate(
rank = rank(-strength), # rank the data by strength; the minus sign indicates descending order
type = "backward", # this is backward associate (i.e., it's woman_BCK)
word = "woman", # the word is "woman" (i.e., it's WOMAN_bck)
associate = cue # for backward associations, the CUE is the associate
)
# Forward and backwards associates to the word "man"
man_fwd <- swow %>%
filter(cue == "man", n_response > 1) %>%
select(-n_response, -n_total) # ... the minus sign means "remove"-
mutate(
rank = rank(-strength), # rank the data by strength; the minus sign indicates descending order
type = "forward", # this is forward associate (i.e., it's man_FWD)
word = "man", # the word is "man" (i.e., it's MAN_fwd)
associate = response # for forward associations, the RESPONSE is the associate
man_bck <- swow %>%
filter(response == "man", n_response > 1) %>%
arrange(desc(strength)) %>%
select(-starts_with("n_")) # ... remove variables starting with "n_"
mutate(
rank = rank(-strength), # rank the data by strength; the minus sign indicates descending order
type = "backward", # this is backward associate (i.e., it's man_BCK)
word = "man", # the word is "man" (i.e., it's MAN_bck)
associate = cue # for backward associations, the CUE is the associate
Combining the data sets
# Creating gender
gender <- bind_rows(woman_fwd, woman_bck, man_fwd, man_bck) %>%
select(id:associate) %>% # Reducing the number of columns
filter(associate !="man", associate !="woman") # Removing the 'boring' associations
Create and plot gender_fwd
# Create gender_fwd
gender_fwd <- gender %>%
filter(
type == "forward"
) %>%
pivot_wider(
id_cols = associate,
names_from = word,
values_from = rank
) %>%
mutate(
woman = replace_na(1/woman, 0),
man = replace_na(1/man, 0),
diff = woman - man
) %>%
arrange(diff)
# Plot gender_fwd
picture_fwd <- ggplot(
data = gender_fwd,
mapping = aes(
x = associate %>% reorder(diff),
y = diff
)) +
geom_col() +
coord_flip()
plot(picture_fwd)
Create and plot gender_bck
# Create gender_bck
gender_bck <- gender %>%
filter(
type == "backward"
) %>%
pivot_wider(
id_cols = associate,
names_from = word,
values_from = rank
) %>%
mutate(
woman = replace_na(1/woman, 0),
man = replace_na(1/man, 0),
diff = woman - man
) %>%
arrange(diff)
# Plot gender_bck
picture_bck <- ggplot(
data = gender_bck,
mapping = aes()
x = associate %>% reorder(diff),
y = diff
)) +
geom_col() +
coord_flip()
plot(picture_bck)
It looks incredibly messy:
Using advice from slack, I decided to reduce the values on the y-axis:
# Plot gender_bck with less values on y-axis
picture_bck <- ggplot(
data = gender_bck %>%
filter(diff < -0.05 | diff > 0.05),
mapping = aes(
x = associate %>% reorder(diff),
y = diff
))+
geom_col() +
coord_flip()
plot(picture_bck)