-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMasterScript.R
More file actions
172 lines (126 loc) · 3.76 KB
/
MasterScript.R
File metadata and controls
172 lines (126 loc) · 3.76 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#Master script
# R version: 4.5.3
gc()
rm(list = ls())
renv::restore()
#Libraries
library(rmarkdown)
library(here)
library(xfun)
if (FALSE) {
# Script Payzan-LeNestour et al. (2024)
root <- here()
setwd(root)
source("Article4_Stubborn/run_full_script.R")
}
# Script Payzan-LeNestour and Woodford (2022)
try(
xfun::Rscript_call(function() {
library(here)
setwd(here::here())
log_file <- "Article1_Outlier/Outlier_log.txt"
# Crear carpeta si no existe (no el archivo)
dir.create(dirname(log_file),
recursive = TRUE,
showWarnings = FALSE)
con <- file(log_file, open = "wt")
sink(con)
sink(con, type = "message")
on.exit({
sink(type = "message")
sink()
sink()
close(con)
}, add = TRUE)
source("Article1_Outlier/Outlier.R", local = TRUE)
}),
silent = FALSE
)
# Script Huber and Huber (2020)
try(
xfun::Rscript_call(function() {
library(here)
setwd(here::here())
log_file <- "Article5_BadBankers/Huber2020_render_log.txt"
dir.create(dirname(log_file),
recursive = TRUE,
showWarnings = FALSE)
con <- file(log_file, open = "wt")
sink(con)
sink(con, type = "message")
on.exit({
sink(type = "message")
sink()
sink()
close(con)
}, add = TRUE)
# Wrapper para ggsave (sin modificar el código del artículo)
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"))
# ← SIN tryCatch (crítico para diagnóstico reproducible)
rmarkdown::render(
input = "Article5_BadBankers/notebook.Rmd",
output_format = "pdf_document",
output_file = "Huber2020_reproduced.pdf",
clean = FALSE,
envir = globalenv(),
quiet = FALSE
)
}),
silent = FALSE
)
# #Script Snijder et al. (2024)
try(
xfun::Rscript_call(function() {
log_file <- "Article7_DecisionMakers/Snijder2024_log.txt"
con <- file(log_file, open = "wt")
# Redirigir stdout y stderr
sink(con)
sink(con, type = "message")
on.exit({
sink(type = "message")
sink()
close(con)
}, add = TRUE)
setwd(here::here())
# Ejecutar scripts con impresión explícita
source("Article7_DecisionMakers/scripts/data_analysis/models.R",
local = TRUE, echo = TRUE)
source("Article7_DecisionMakers/scripts/data_analysis/partner choice.R",
local = TRUE, echo = TRUE)
source("Article7_DecisionMakers/scripts/data_analysis/plots.R",
local = TRUE, echo = TRUE)
source("Article7_DecisionMakers/scripts/data_analysis/political orientation.R",
local = TRUE, echo = TRUE)
source("Article7_DecisionMakers/scripts/process_data/process data.R",
local = TRUE, echo = TRUE)
}),
silent = FALSE
)
# #Script Ekström et al. (2025), (R part)
try(
xfun::Rscript_call(function() {
log_file <- "Article12_MakingAPromise/MakingAPromise_log.txt"
# Abrir conexión de log
con <- file(log_file, open = "wt")
# Redirigir stdout y stderr
sink(con)
sink(con, type = "message")
on.exit({
sink(type = "message")
sink()
close(con)
}, add = TRUE)
library(here)
setwd(here::here())
source("Article12_MakingAPromise/MakingAPromise.R", local = TRUE)
}),
silent = FALSE
)