Skip to content

Instantly share code, notes, and snippets.

@steveharoz
Last active June 20, 2023 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveharoz/de004533a52c403157e4143556fbe068 to your computer and use it in GitHub Desktop.
Save steveharoz/de004533a52c403157e4143556fbe068 to your computer and use it in GitHub Desktop.
datacolada 110 replot

Data Colada Plot

The singular point in the top left is pointed out as the lower case harvard point

image

Steve's Plot

Notice that the purple diamond for lower-case-harvard is not the same as the singular point in the top left

image

library(tidyverse)
library(foreign) # for read.spss()
library(ggdist) # for geom_dots()
# load the data
# source: https://osf.io/sd76g/
data = foreign::read.spss("data_Experiment_4.sav", to.data.frame=TRUE) %>%
as_tibble()
data = data %>%
# clean up string columns
mutate(across(where(is.character), str_trim)) %>%
# identify "harvard" and "Harvard" responses
mutate(harvard = ifelse(str_to_lower(yearSchool) == "harvard", yearSchool, "no red flags")) %>%
# combine conditions
mutate(condition2 = ifelse(condition == "ProAttitudinal", "Argued Own Side\n(Predicted LOW)", "Argued Other Side\n(Predicted HIGH)")) %>%
mutate(condition2 = fct_rev(factor(condition2)))
# show the lower case data point
data %>%
filter(yearSchool == "harvard") %>%
select(yearSchool, condition, condition2, av_products_clean)
# # A tibble: 1 × 4
# yearSchool condition condition2 av_products_clean
# <chr> <chr> <fct> <dbl>
# 1 harvard No_Choice "Argued Other Side\n(Predicted HIGH)" 7
ggplot(data) +
aes(x=condition2, y=av_products_clean, fill=harvard, alpha=harvard, shape=harvard, group=NA) +
ggdist::geom_dots(side="both", position="dodge", color=NA) +
scale_fill_manual( values = c(`no red flags` = "#377EB8", Harvard = "#E41A1C", harvard = "#984EA3")) +
scale_shape_manual(values = c(`no red flags` = 21, Harvard = 22, harvard = 23)) +
scale_alpha_manual(values = c(`no red flags` = 0.4, Harvard = 1, harvard = 1)) +
theme_classic(18) +
theme(axis.line.x = element_blank(), axis.ticks.x = element_blank()) +
labs(fill = NULL, alpha = NULL, shape = NULL, x = NULL,
y = "Evaluation of Cleansing Products",
title = "'Harvard' Class Year Observations Are Extremely Supportive of Predicted Pattern",
subtitle = "Gino, Kouchaki, & Galinsky (2015) - Study 4")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment