-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.R
48 lines (38 loc) · 1.35 KB
/
resources.R
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
optim_to_latex <- function(x, label = "table:optimal_params", caption = "Optimal Parameters", param_labels = NULL) {
require(dplyr)
if (is.null(param_labels)) {
param_labels <- paste0("Parameter ", seq_along(x$par))
}
method <- x$method
table_data <- data.frame(Parameter = param_labels,
Value = round(x$par,3))
latex_code <- paste0("\\begin{table}[h!]\n",
"\\centering\n",
"\\caption{", caption, "}\\label{", label, "}\n",
"\\begin{tabular}{cc}\n \\hline \n",
'Parameter & Estimate \\\\ \\hline \n')
for (i in seq(nrow(table_data))) {
latex_code <- paste0(latex_code, table_data[i, "Parameter"], " & ", table_data[i, "Value"], " \\\\ \n")
}
latex_code <- paste0(latex_code,
"\\hline\n", "\\end{tabular}\n",
"\\end{table}\n")
cat(latex_code)
return(latex_code)
}
my_col <- c(
'#274C77',
'#6096BA',
'#A3CEF1',
'#8B8C89'
)
my_palette <- function(n = 1){
return(my_col[1:n])
}
my_theme <- theme_light(base_size = 20) +
theme(
strip.background=element_rect(colour=my_palette(1),
fill=my_palette(1)),
axis.text = element_text(color = 'black'),
text = element_text(family = 'Lato')
)