Repository navigation
Expand file tree
/
Copy pathMasterScript.R
More file actions
117 lines (99 loc) · 4.22 KB
/
Copy pathMasterScript.R
File metadata and controls
117 lines (99 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# =============================================================================
# MASTER SCRIPT
# R version: 4.6.0
# =============================================================================
gc()
rm(list = ls())
renv::restore(prompt = FALSE)
library(rmarkdown)
library(xfun)
source("R/run_script_project.R")
# =============================================================================
# PAPERS TO RUN
# =============================================================================
# Payzan-LeNestour et al. (2026)
run_script_project(
log_file = "payzan-lenestourStubbornDesignNeurobiological/Stubborn_log.txt",
expr = {
assignInNamespace("getActiveDocumentContext",
function(...) list(path = file.path(here::here(), "run_full_script.R")),
ns = "rstudioapi")
local({
orig <- get("effectsize", envir = asNamespace("effectsize"))
assignInNamespace("effectsize", function(x, ...) {
tryCatch(orig(x, ...), error = function(e) {
message("effectsize error (skipped): ", conditionMessage(e))
invisible(NULL)
})
}, ns = "effectsize")
})
source("payzan-lenestourStubbornDesignNeurobiological/Reproducibility/run_full_script.R", local = TRUE)
}
)
# Payzan-LeNestour and Woodford (2022)
run_script_project(
log_file = "payzan-lenestourOutlierBlindnessNeurobiological2022/Outlier_log.txt",
expr = {
source("payzan-lenestourOutlierBlindnessNeurobiological2022/Outlier.R", local = TRUE)
}
)
# Huber and Huber (2020)
run_script_project(
log_file = "huberBadBankersNo2020/Huber2020_log.txt",
expr = {
library(here)
setwd(here::here())
# Parche stargazer
sg_path <- find.package("stargazer")
tmp_tar <- tempfile(fileext = ".tar.gz")
download.file("https://cran.r-project.org/src/contrib/stargazer_5.2.3.tar.gz",
destfile = tmp_tar, quiet = TRUE)
tmp_dir <- tempdir()
untar(tmp_tar, exdir = tmp_dir)
code <- readLines(file.path(tmp_dir, "stargazer", "R", "stargazer-internal.R"))
l1 <- grep("if (is.na(s))", code, fixed = TRUE)
code[l1] <- gsub("if (is.na(s))", "if (length(s) == 0 || all(is.na(s)))", code[l1], fixed = TRUE)
l2 <- grep('if (s=="")', code, fixed = TRUE)
code[l2] <- gsub('if (s=="")', 'if (length(s) == 0 || all(s == ""))', code[l2], fixed = TRUE)
writeLines(code, file.path(tmp_dir, "stargazer", "R", "stargazer-internal.R"))
install.packages(file.path(tmp_dir, "stargazer"), repos = NULL, type = "source", quiet = TRUE, lib = dirname(sg_path))
cat("stargazer parcheado para R 4.x\n")
assignInNamespace("tbl_df", tibble::as_tibble, ns = "dplyr")
unlockBinding("ggsave", asNamespace("ggplot2"))
original_ggsave <- ggplot2::ggsave
assign("ggsave", function(filename, ...) {
dir.create(dirname(filename), recursive = TRUE, showWarnings = FALSE)
original_ggsave(filename, ...)
}, envir = asNamespace("ggplot2"))
lockBinding("ggsave", asNamespace("ggplot2"))
rmarkdown::render(
input = "huberBadBankersNo2020/notebook.Rmd",
output_format = "pdf_document",
output_file = "Huber2020_reproduced.pdf",
clean = FALSE,
envir = globalenv(),
quiet = FALSE
)
}
)
# Snijder et al. (2024)
run_script_project(
log_file = "snijderDecisionmakersSelfservinglyNavigate2024/Snijder2024_log.txt",
expr = {
library(here)
setwd(here::here())
source("snijderDecisionmakersSelfservinglyNavigate2024/scripts/data_analysis/models.R", local = TRUE)
source("snijderDecisionmakersSelfservinglyNavigate2024/scripts/data_analysis/partner choice.R", local = TRUE)
source("snijderDecisionmakersSelfservinglyNavigate2024/scripts/data_analysis/plots.R", local = TRUE)
source("snijderDecisionmakersSelfservinglyNavigate2024/scripts/data_analysis/political orientation.R", local = TRUE)
source("snijderDecisionmakersSelfservinglyNavigate2024/scripts/process_data/process data.R", local = TRUE)
}
)
# Ekström et al. (2025)
run_script_project(
log_file = "ekstromMakingPromiseIncreases2025/MakingAPromise_log.txt",
expr = {
source("ekstromMakingPromiseIncreases2025/MakingAPromise.R", local = TRUE)
}
)
message("\n=== END SCRIPT ===\n")