Skip to content

Commit

Permalink
mod tree
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceOMFoisy committed Jun 19, 2024
1 parent b030515 commit 38885b0
Show file tree
Hide file tree
Showing 39 changed files with 6,521 additions and 503 deletions.
2 changes: 1 addition & 1 deletion code/analysis_anglo_sax.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library(tidyr)
library(dplyr)
library(ggplot2)

data_party <- readRDS("_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/data_party.rds")
data_party <- readRDS("data/expert_survey/data_party.rds")

data_econ <- data_party %>%
group_by(group) %>%
Expand Down
4 changes: 2 additions & 2 deletions code/analysis_base.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ library(tidyr)
library(ggridges)
library(ggplot2)

data_party <- readRDS("_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/data_party.rds")
data_party <- readRDS("data/expert_survey/data_party.rds")

# Graphique nuage de points -------------------------------------- #

Expand Down Expand Up @@ -210,6 +210,6 @@ ggplot(h1, aes(x = gps, y = gpt)) +
axis.title.y = element_text(hjust = 0.5),
axis.text.y = element_text(angle = 90))

ggsave("_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h1_scatterplot.png",
ggsave("data/graphs/h1_scatterplot.png",
width = 8, height = 6)

6 changes: 3 additions & 3 deletions code/analysis_categorical.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library(dplyr)
library(tidyr)
library(ggplot2)

data_party <- readRDS("_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/data_party.rds")
data_party <- readRDS("data/expert_survey/data_party.rds")


h3 <- data_party %>%
Expand Down Expand Up @@ -67,7 +67,7 @@ ggplot(h3, aes(x = position, y = type)) +
strip.text = element_text(size = 20)) # Bold and increased size for facet labels


ggsave("_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h3_distggridges.png",
ggsave("data/graphs/h3_distggridges.png",
width = 10, height = 6)


Expand Down Expand Up @@ -129,5 +129,5 @@ ggplot(long_data2, aes(x = alignment, y = mean_distance, fill = alignment_type))
plot.caption.position = "plot") # Positioning the caption relative to the plot


ggsave("_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h3_barplot.png",
ggsave("data/graphs/h3_barplot.png",
width = 10, height = 6)
6 changes: 3 additions & 3 deletions code/analysis_left.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library(dplyr)
library(tidyr)
library(ggplot2)

data_party <- readRDS("_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/data_party.rds")
data_party <- readRDS("data/expert_survey/data_party.rds")

## h3 for paper

Expand Down Expand Up @@ -48,7 +48,7 @@ ggplot(h3, aes(x = position, y = type)) +
axis.text.y = element_text(size = 20), # Bold and increased size
strip.text = element_text(size = 20)) # Bold and increased size for facet labels

ggsave("_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h3_distggridges.png",
ggsave("data/graphs/h3_distggridges.png",
width = 10, height = 6)

# Reshape and filter data as before
Expand Down Expand Up @@ -108,7 +108,7 @@ ggplot(long_data2, aes(x = alignment, y = mean_distance, fill = alignment_type))
legend.key.size = unit(1.5, "lines"), # Bolder and larger plot caption
plot.caption.position = "plot") # Positioning the caption relative to the plot

ggsave("_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h3_barplot.png",
ggsave("data/graphs/h3_barplot.png",
width = 10, height = 6)


6 changes: 3 additions & 3 deletions code/analysis_party_size.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library(dplyr)
library(tidyr)
library(ggplot2)

data_party <- readRDS("_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/data_party.rds")
data_party <- readRDS("data/expert_survey/data_party.rds")

long_data <- data_party %>%
select(Type_Partysize_seat, econ_distance, sos_distance) %>%
Expand Down Expand Up @@ -53,7 +53,7 @@ ggplot(long_data2, aes(x = partysize, y = mean_distance, fill = distance_type))
legend.text = element_text(size = 20), # Increase legend text size
legend.key.size = unit(1.5, "lines")) # Bolder and larger plot caption

ggsave("_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h4_barplot.png",
ggsave("data/graphs/h4_barplot.png",
width = 8, height = 6)


Expand All @@ -74,6 +74,6 @@ ggplot(long_data2, aes(x = alignment, y = mean_distance, fill = alignment_type))
theme(axis.title.x = element_text(hjust = 0.5),
axis.title.y = element_text(hjust = 0.5))

ggsave("_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h3_barplot.png",
ggsave("data/graphs/h3_barplot.png",
width = 10, height = 6)

4 changes: 2 additions & 2 deletions code/analysis_west.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library(tidyr)
library(dplyr)
library(ggplot2)

data_party <- readRDS("_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/data_party.rds")
data_party <- readRDS("data/expert_survey/data_party.rds")

# ------------------ Distance graph ---------------------------- #

Expand Down Expand Up @@ -72,5 +72,5 @@ ggplot(long_data2, aes(x = reorder(Region_name, -mean_distance),
_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h3_distggridges.png


ggsave("_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h2_barplot.png",
ggsave("data/graphs/h2_barplot.png",
width = 8, height = 6)
6 changes: 3 additions & 3 deletions code/cleaning_wrangling.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library(dplyr)
library(tidyr)
library(ggplot2)

data_party <- readRDS("_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/gps_gpt_final.rds")
data_party <- readRDS("data/expert_survey/gps_gpt_final.rds")

data_party$econ_distance <- abs(data_party$V4_Scale - data_party$econ_ideo_gpt_mean)
data_party$sos_distance <- abs(data_party$V6_Scale - data_party$sos_ideo_gpt_mean)
Expand Down Expand Up @@ -80,6 +80,6 @@ data_party$sos_ideo_cat_gpt[data_party$sos_ideo_gpt_mean > 5 & data_party$sos_id
data_party$sos_ideo_cat_gpt[data_party$sos_ideo_gpt_mean > 6 & data_party$sos_ideo_gpt_mean <= 8] <- 6
data_party$sos_ideo_cat_gpt[data_party$sos_ideo_gpt_mean > 8] <- 7

write.csv(data_party, "_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/data_party.csv")
write.csv(data_party, "data/expert_survey/data_party.csv")

saveRDS(data_party, "_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/data_party.rds")
saveRDS(data_party, "data/expert_survey/data_party.rds")
18 changes: 9 additions & 9 deletions code/prompting_experts.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ library(openai)
library(stringr)


data_party <- read.csv("_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/dataverse_files/Global Party Survey by Party SPSS V2_1_Apr_2020-2.csv")
data_party <- read.csv("data/expert_survey/dataverse_files/Global Party Survey by Party SPSS V2_1_Apr_2020-2.csv")

#Ideology
#Partyname
Expand Down Expand Up @@ -60,9 +60,9 @@ for (run in 1:3) {
}
}

write.csv(data_party, "_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/gps_gpt_uncleaned.csv")
write.csv(data_party, "data/expert_survey/gps_gpt_uncleaned.csv")

saveRDS(data_party, "_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/gps_gpt_uncleaned.rds")
saveRDS(data_party, "data/expert_survey/gps_gpt_uncleaned.rds")

data_party$econ_ideo_gpt_1 <- ifelse(nchar(data_party$econ_ideo_gpt_run1) > 10, NA, data_party$econ_ideo_gpt_run1)
data_party$econ_ideo_gpt_2 <- ifelse(nchar(data_party$econ_ideo_gpt_run2) > 10, NA, data_party$econ_ideo_gpt_run2)
Expand All @@ -74,9 +74,9 @@ data_party$econ_ideo_gpt_3 <- as.numeric(data_party$econ_ideo_gpt_3)

data_party$econ_ideo_gpt_mean <- rowMeans(data_party[, c("econ_ideo_gpt_1", "econ_ideo_gpt_2", "econ_ideo_gpt_3")], na.rm = TRUE)

write.csv(data_party, "_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/gps_gpt.csv")
write.csv(data_party, "data/expert_survey/gps_gpt.csv")

saveRDS(data_party, "_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/gps_gpt.rds")
saveRDS(data_party, "data/expert_survey/gps_gpt.rds")

# ------------------- PROMPTING V6 LIBERALISM VS CONSERVATISM ------------------

Expand Down Expand Up @@ -129,9 +129,9 @@ for (run in 1:3) {
}
}

write.csv(data_party, "_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/gps_gpt_uncleaned_sos.csv")
write.csv(data_party, "data/expert_survey/gps_gpt_uncleaned_sos.csv")

saveRDS(data_party, "_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/gps_gpt_uncleaned_sos.rds")
saveRDS(data_party, "data/expert_survey/gps_gpt_uncleaned_sos.rds")

data_party$sos_ideo_gpt_1 <- ifelse(nchar(data_party$sos_ideo_gpt_run1) > 10, NA, data_party$sos_ideo_gpt_run1)
data_party$sos_ideo_gpt_2 <- ifelse(nchar(data_party$sos_ideo_gpt_run2) > 10, NA, data_party$sos_ideo_gpt_run2)
Expand All @@ -143,8 +143,8 @@ data_party$sos_ideo_gpt_3 <- as.numeric(data_party$sos_ideo_gpt_3)

data_party$sos_ideo_gpt_mean <- rowMeans(data_party[, c("sos_ideo_gpt_1", "sos_ideo_gpt_2", "sos_ideo_gpt_3")], na.rm = TRUE)

write.csv(data_party, "_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/gps_gpt_final.csv")
write.csv(data_party, "data/expert_survey/gps_gpt_final.csv")

saveRDS(data_party, "_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/gps_gpt_final.rds")
saveRDS(data_party, "data/expert_survey/gps_gpt_final.rds")


6 changes: 3 additions & 3 deletions code/t_test_mean_distance.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
library(dplyr)
library(ggplot2)

data_party <- readRDS("_SharedFolder_article_spsa2024_gpt_party/data/expert_survey/data_party.rds")
data_party <- readRDS("data/expert_survey/data_party.rds")

# ---------------------- T Test ------------------------------------------------

Expand Down Expand Up @@ -76,7 +76,7 @@ ggplot(results, aes(x = MeanDifference, y = Category)) +
axis.text.y = element_text(size = 20),
plot.caption = element_text(size = 20, hjust = 0))

ggsave("_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h1_ttest.png",
ggsave("data/graphs/h1_ttest.png",
width = 8, height = 6)

h1 <- data_party %>%
Expand Down Expand Up @@ -153,7 +153,7 @@ ggplot(results, aes(x = MeanDifference, y = Category)) +
axis.text.y = element_text(size = 20),
plot.caption = element_text(size = 20, hjust = 0))

ggsave("_SharedFolder_article_spsa2024_gpt_party/graphs/paper/h1_ttest.png",
ggsave("data/graphs/h1_ttest.png",
width = 8, height = 6)

h1 <- data_party %>%
Expand Down
131 changes: 0 additions & 131 deletions code/wikidata/alignment_prompt.r

This file was deleted.

Loading

0 comments on commit 38885b0

Please sign in to comment.