-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.R
138 lines (117 loc) · 5.59 KB
/
compile.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
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
## RScript doesn't load the same environment variables as your RStudio session, so find your path executing `quarto:::find_quarto()`:
Sys.setenv(QUARTO_PATH="/usr/lib/rstudio/resources/app/bin/quarto/bin/quarto")
# package instalation -----------------------------------------------------
# install.packages(c("tidyverse", "readxl", "quarto"))
# data transform ----------------------------------------------------------
suppressPackageStartupMessages(library(tidyverse))
df <- read_csv("data.csv", show_col_types = FALSE)
df |>
slice(1) |>
mutate(day = day + 1) |>
bind_rows(df) |>
arrange(desc(year), desc(month), desc(day)) |>
mutate(day2 = ifelse(lag(day) == day & lag(month) == month, NA, day),
month2 = ifelse(lag(day) == day & lag(month) == month, NA, month),
day = day2,
abstract = ifelse(is.na(abstract), "", abstract),
month = month2) |>
slice(-1) |>
mutate(month_ru = case_when(month == 1 ~ "января",
month == 2 ~ "февраля",
month == 3 ~ "марта",
month == 4 ~ "апреля",
month == 5 ~ "мая",
month == 6 ~ "июня",
month == 7 ~ "июля",
month == 8 ~ "августа",
month == 9 ~ "сентября",
month == 10 ~ "октября",
month == 11 ~ "ноября",
month == 12 ~ "декабря"),
month_en = case_when(month == 1 ~ "January",
month == 2 ~ "February",
month == 3 ~ "March",
month == 4 ~ "April",
month == 5 ~ "May",
month == 6 ~ "June",
month == 7 ~ "July",
month == 8 ~ "August",
month == 9 ~ "September",
month == 10 ~ "October",
month == 11 ~ "November",
month == 12 ~ "December")) ->
df
# create russian part -----------------------------------------------------
file.remove("result_ru.qmd")
str_c("\n\n## Семинары [международной лаборатории языковой конвергенции](https://ilcl.hse.ru/)\n\n
Если вы хотите участвовать в семинарах лаборатории, вы можете зарегистрироваться [здесь](https://ilcl.hse.ru/en/polls/420288221.html).
") |>
write_lines("result_ru.qmd", append = TRUE)
walk(unique(df$year), function(i){
df |>
filter(year == i) ->
data_generate_text
str_c("\n\n### Расписание семинаров в ", i, " году\n\n
:::: {.columns}
\n\n") |>
write_lines("result_ru.qmd", append = TRUE)
walk(seq_along(data_generate_text$title), function(j){
data_generate_text |>
slice(j) |>
mutate(one_talk = str_c("::: {.column width='15%'}\n\n",
ifelse(is.na(day), "", str_c("**", day)),
" ",
ifelse(is.na(month_ru), "", str_c(month_ru, "**")),
"\n\n",
":::\n\n",
"::: {.column width='85%'}\n\n",
"*", author, "*\n\n",
"**", title, "**\n\n",
"<details><summary>Аннотация</summary>\n\n",
abstract,
"</details>\n\n",
":::\n\n")) |>
pull(one_talk) |>
write_lines("result_ru.qmd", append = TRUE)
})
str_c("::::\n\n") |>
write_lines("result_ru.qmd", append = TRUE)
})
quarto::quarto_render("result_ru.qmd")
# create english part -----------------------------------------------------
file.remove("result_en.qmd")
str_c("\n\n## Seminars of the [Linguistic Convergence Laboratory](https://ilcl.hse.ru/en/)\n\n
If you are interested in participating in the laboratory seminars, please register [here](https://ilcl.hse.ru/en/polls/420288221.html).
") |>
write_lines("result_en.qmd", append = TRUE)
walk(unique(df$year), function(i){
df |>
filter(year == i) ->
data_generate_text
str_c("\n\n### Seminar schedule ", i, "\n\n
:::: {.columns}
\n\n") |>
write_lines("result_en.qmd", append = TRUE)
walk(seq_along(data_generate_text$title), function(j){
data_generate_text |>
slice(j) |>
mutate(one_talk = str_c("::: {.column width='15%'}\n\n",
ifelse(is.na(day), "", str_c("**", day)),
" ",
ifelse(is.na(month_en), "", str_c(month_en, "**")),
"\n\n",
":::\n\n",
"::: {.column width='85%'}\n\n",
"*", author, "*\n\n",
"**", title, "**\n\n",
"<details><summary>Abstract</summary>\n\n",
abstract,
"</details>\n\n",
":::\n\n")) |>
pull(one_talk) |>
write_lines("result_en.qmd", append = TRUE)
})
str_c("::::\n\n") |>
write_lines("result_en.qmd", append = TRUE)
})
quarto::quarto_render("result_en.qmd")