-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline.Rmd
1564 lines (944 loc) · 36.9 KB
/
pipeline.Rmd
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Compilation Report | Corpus of Resolutions: UN Security Council"
author: "Seán Fobbe, Lorenzo Gasbarri and Niccoló Ridi"
geometry: margin=3cm
fontsize: 11pt
papersize: a4
output:
pdf_document:
toc: true
toc_depth: 3
number_sections: true
pandoc_args: --listings
includes:
in_header: tex/Preamble_EN.tex
before_body: [temp/Definitions.tex, tex/Titlepage_Compilation.tex]
bibliography: temp/packages.bib
nocite: '@*'
---
<!-- Copyright (C) 2024 Seán Fobbe, Lorenzo Gasbarri and Niccoló Ridi -->
<!-- This program is free software: you can redistribute it and/or modify -->
<!-- it under the terms of the GNU General Public License as published by -->
<!-- the Free Software Foundation, either version 3 of the License, or -->
<!-- (at your option) any later version. -->
<!-- This program is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
<!-- GNU General Public License for more details. -->
<!-- You should have received a copy of the GNU General Public License -->
<!-- along with this program. If not, see <https://www.gnu.org/licenses/>. -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE,
warning = TRUE,
message = TRUE,
collapse = TRUE,
comment = "#>")
```
```{r, results = "asis", echo = FALSE}
cat(readLines("README.md"),
sep = "\n")
```
# Load Packages
```{r}
library(targets)
library(tarchetypes)
library(RcppTOML)
library(future)
library(data.table)
library(quanteda)
library(knitr)
library(kableExtra)
library(igraph)
library(ggraph)
tar_unscript()
```
# Preamble
## Definitions
```{r}
## Datestamp
datestamp <- Sys.Date()
print(datestamp)
## Date and Time (Begin)
begin.script <- Sys.time()
## Read Configuration
config <- RcppTOML::parseTOML("config.toml")
print(config)
# Define Analysis Folder
dir.analysis <- paste0(getwd(),
"/analysis")
```
## Clean Up
Deletes temporary files and files in the output folder that do not match the datestamp.
```{r}
unlink(list.files(pattern = "\\.tiff"))
unlink(grep(datestamp,
list.files("output",
full.names = TRUE),
invert = TRUE,
value = TRUE))
unlink("temp")
unlink("temp_tesseract")
```
## Create Folders
```{r}
dirs <- c("output",
"temp")
lapply(dirs, dir.create, showWarnings = FALSE)
dir.create(dir.analysis, showWarnings = FALSE)
```
## Write Package Citations
```{r}
knitr::write_bib(renv::dependencies()$Package,
"temp/packages.bib")
```
# Global Variables
## Define Packages
```{targets global-packages, tar_globals = TRUE}
tar_option_set(packages = c("tarchetypes", # Additional targets functions
"RcppTOML", # Read and write TOML files
"zip", # Enhanced ZIP handling
"testthat", # Unit tests
"rvest", # Web Scraping
"knitr", # Scientific reporting
"kableExtra", # Enhanced kable tables
"ggplot2", # Advanced data vizualization
"ggraph", # Graph visualization
"igraph", # Graph analaysis
"scales", # Scaling of figures
"magick", # Image processing
"viridis", # Viridis palette
"RColorBrewer", # ColorBrewer palette
"pdftools", # Extract PDF files
"readtext", # Read TXT files
"stringi", # String manipulation
"quanteda", # Advanced computer linguistics
"quanteda.textstats", # Text statistics
"quanteda.textplots", # Text visualizations
"textcat", # Language Classification of Text
"future", # Parellel computing
"future.apply", # Higher-order functions for future
"data.table" # Advanced tabular data processing
)
)
tar_option_set(workspace_on_error = TRUE) # Save Workspace on Error
tar_option_set(format = "qs")
```
## Configuration
```{targets global-config, tar_globals = TRUE}
datestamp <- Sys.Date()
config <- RcppTOML::parseTOML("config.toml")
dir.analysis <- paste0(getwd(),
"/analysis")
## Caption for diagrams
caption <- paste("Fobbe/Gasbarri/Ridi | DOI:",
config$doi$data$version)
## Prefix for figure titles
prefix.figuretitle <- paste(config$project$shortname,
"| Version",
datestamp)
## File prefix
prefix.files <- paste0(config$project$shortname,
"_",
datestamp)
if (config$cores$max == TRUE){
fullCores <- parallel::detectCores()
tesseractJobs <- round(fullCores / 4) + 1
}
if (config$cores$max == FALSE){
fullCores <- as.integer(config$cores$number)
tesseractJobs <- as.integer(config$cores$tesseract)
}
```
## Define Functions
```{targets global-functions, tar_globals = TRUE}
lapply(list.files("functions", pattern = "\\.R$", full.names = TRUE), source)
```
## Define Metadata for TXT Files
```{targets global-txtvars, tar_globals = TRUE}
docvarnames <- c("body",
"doctype",
"res_no",
"year",
"language")
```
## Define Source Files
```{targets global-sourcefiles, tar_globals = TRUE}
files.source.raw <- c(system2("git", "ls-files", stdout = TRUE), ".git")
```
# Pipeline: Construction
## File Read Targets
Defines targets that track and read input data files. Source files are not read into R, but tracked to serve as a trigger for rebuilding the relevant ZIP archive.
### Source Code
```{targets tar.file.source}
tar_target(files.source,
files.source.raw,
format = "file")
```
### Changelog
```{targets tar.file.changelog}
tar_target(changelog,
"CHANGELOG.md",
format = "file")
```
### Table of Main Record Pages (Stable)
This file contains a stable and checked list of resolutions numbers and the corresponding UN Digital Library records pages for the resolution texts and meta data.
```{targets tar.file.recordpages.main}
list(
tar_target(csv.record.table,
"data/UNSC_Record-Table_2722.csv",
format = "file"),
tar_target(record.table.stable,
fread(csv.record.table))
)
```
### Table of Voting Record Pages (Stable)
This file contains a stable and checked list of resolutions numbers and the corresponding UN Digital Library records pages for voting data.
```{targets tar.file.recordpages.voting}
list(
tar_target(csv.record.voting,
"data/UNSC_Record_Voting_2722.csv",
format = "file"),
tar_target(record.voting.stable,
fread(csv.record.voting))
)
```
### Table of Variables
All variables in the data set, including their description.
```{targets tar.file.vars}
list(
tar_target(file.var_codebook,
"data/CR-UNSC_Variables.csv",
format = "file"),
tar_target(dt.var_codebook,
fread(file.var_codebook))
)
```
### Gold Standard Resolutions
Gold standard resolution texts are OCR texts with all extraneous information removed and errors corrected by hand.
```{targets tar.file.goldres}
list(
tar_target(txt_res_en_gold,
list.files("data/res_en_gold", pattern = ".txt", full.names = TRUE),
format = "file"),
tar_target(dt_res_en_gold,
f.readtext(x = txt_res_en_gold,
docvarnames = docvarnames))
)
```
## Download
### Define Scope of Resolution Numbers
The full set of resolution numbers that makes up the data set is defined. The scope() function supports selecting resolution numbers from 1 through a defined limit (full scope) and a random subset (debugging mode). You can replace the output of the function with any arbitrary set of resolution numbers and it should work as well.
```{targets tar.download.resno}
tar_target(res.no.full,
f.scope(limit = config$download$resmax,
debug.toggle = config$debug$toggle,
debug.sample = config$debug$sample))
```
### Build Table of Main Record Pages (Final)
This step builds the final table of UN Digital Library main records containing the links to full texts and resolution metadata. It draws on a pre-built list to speed up the download and reduce load on UN servers.
```{targets tar.download.recordtable.main}
tar_target(dt.record.final,
f.record_main(record.table.stable = record.table.stable,
res.no.full = res.no.full))
```
### Build Table of Voting Record Pages (Final)
This step builds the final table of UN Digital Library records containing voting data. It draws on a pre-built list to speed up the download and reduce load on UN servers.
```{targets tar.download.recordtable.voting}
tar_target(dt.record.voting.final,
f.record_voting(recordtable.stable = record.voting.stable,
res.no.full = res.no.full))
```
### Download HTML Main Records for Resolutions
```{targets tar.download.records.res.main}
tar_target(html.record.res,
f.download(url = dt.record.final$url_record,
filename = paste0(stringi::stri_pad_left(dt.record.final$res_no, width = 4, pad = "0"), ".html"),
dir = "files/record_resolution",
sleep.min = 0.5,
sleep.max = 1,
retries = 3,
retry.sleep.min = 2,
retry.sleep.max = 5,
timeout = config$download$timeout,
debug.toggle = FALSE),
format = "file")
```
### Download HTML Voting Records for Resolutions
```{targets tar.download.records.res.voting}
tar_target(html.record.voting,
f.download(url = dt.record.voting.final$url_record,
filename = paste0(stringi::stri_pad_left(dt.record.voting.final$res_no, width = 4, pad = "0"), ".html"),
dir = "files/record_voting",
sleep.min = 0.5,
sleep.max = 1,
retries = 3,
retry.sleep.min = 2,
retry.sleep.max = 5,
timeout = config$download$timeout,
debug.toggle = FALSE),
format = "file")
```
### Parse Resolution HTML Records
```{targets tar.download.parse.res}
tar_target(dt.download,
f.parse_records_full(html.record.res))
```
### Parse Voting HTML Records
```{targets tar.download.parse.voting}
tar_target(dt.voting,
f.parse_records_voting(html.record.voting))
```
### Download HTML Records for Drafts
```{targets tar.download.records.draft}
tar_target(html.record.draft,
f.download(url = dt.download[!is.na(url_record_draft)]$url_record_draft,
filename = paste0(stringi::stri_pad_left(dt.download[!is.na(url_record_draft)]$res_no, width = 4, pad = "0"), ".html"),
dir = "files/record_draft",
sleep.min = 0.5,
sleep.max = 1,
retries = 3,
retry.sleep.min = 5,
retry.sleep.max = 10,
timeout = config$download$timeout,
debug.toggle = FALSE),
format = "file")
```
### Download HTML Records for Meeting Records
```{targets tar.download.records.meeting}
tar_target(html.record.meeting,
f.download(url = dt.download[!is.na(url_record_meeting)]$url_record_meeting,
filename = paste0(stringi::stri_pad_left(dt.download[!is.na(url_record_meeting)]$res_no, width = 4, pad = "0"), ".html"),
dir = "files/record_meeting",
sleep.min = 1,
sleep.max = 1.5,
retries = 3,
retry.sleep.min = 5,
retry.sleep.max = 10,
timeout = config$download$timeout,
debug.toggle = FALSE),
format = "file")
```
### Parse Draft HTML Records
```{targets tar.download.parse.draft}
tar_target(url.draft,
f.parse_records_url(html.record.draft,
prefix = "url_draft_"))
```
### Parse Meeting HTML Records
```{targets tar.download.parse.meeting}
tar_target(url.meeting,
f.parse_records_url(html.record.meeting,
prefix = "url_meeting_"))
```
### Finalize Download Table
```{targets tar.download.table.final}
tar_target(dt.download.final,
f.download_manifest(dt.download = dt.download,
dt.record = dt.record.final,
url.meeting = url.meeting,
url.draft = url.draft))
```
### Download, OCR, Extract and Read PDF Texts
```{targets tar.download}
values <- tibble::tibble(
name = c("res_ar",
"res_zh",
"res_en",
"res_fr",
"res_ru",
"res_es",
"draft_en",
"meeting_en"),
url = c(quote(dt.download.final[!is.na(url_res_ar)]$url_res_ar),
quote(dt.download.final[!is.na(url_res_zh)]$url_res_zh),
quote(dt.download.final[!is.na(url_res_en)]$url_res_en),
quote(dt.download.final[!is.na(url_res_fr)]$url_res_fr),
quote(dt.download.final[!is.na(url_res_ru)]$url_res_ru),
quote(dt.download.final[!is.na(url_res_es)]$url_res_es),
quote(dt.download.final[!is.na(url_draft_en)]$url_draft_en),
quote(dt.download.final[!is.na(url_meeting_en)]$url_meeting_en)),
filename = c(quote(paste0(dt.download.final[!is.na(url_res_ar)]$doc_id, "_AR.pdf")),
quote(paste0(dt.download.final[!is.na(url_res_zh)]$doc_id, "_ZH.pdf")),
quote(paste0(dt.download.final[!is.na(url_res_en)]$doc_id, "_EN.pdf")),
quote(paste0(dt.download.final[!is.na(url_res_fr)]$doc_id, "_FR.pdf")),
quote(paste0(dt.download.final[!is.na(url_res_ru)]$doc_id, "_RU.pdf")),
quote(paste0(dt.download.final[!is.na(url_res_es)]$doc_id, "_ES.pdf")),
quote(paste0(dt.download.final[!is.na(url_draft_en)]$doc_id, "_Draft_EN.pdf")),
quote(paste0(dt.download.final[!is.na(url_meeting_en)]$doc_id, "_MeetingRec_EN.pdf"))),
dir = c("files/pdf_res_ar",
"files/pdf_res_zh",
"files/pdf_res_en",
"files/pdf_res_fr",
"files/pdf_res_ru",
"files/pdf_res_es",
"files/pdf_draft_en",
"files/pdf_meeting_en"),
tesslang = c("ara",
"chi_sim",
"eng",
"fra",
"rus",
"spa",
"eng",
"eng"))
zip.list <- tarchetypes::tar_map(unlist = FALSE,
values = values,
names = name,
tar_target(pdf,
f.download(url = url,
filename = filename,
dir = dir,
sleep.min = 0.3,
sleep.max = 1,
retries = 3,
retry.sleep.min = 2,
retry.sleep.max = 5,
timeout = config$download$timeout,
debug.toggle = FALSE),
format = "file"),
tar_target(ocr,
f.tar_pdf_ocr(grep("S_RES_0[0-8][0-9][0-9]",
pdf,
value = TRUE),
dpi = 300,
lang = tesslang,
crop.firstpage = 0,
crop.lastpage = 0,
output = "pdf txt",
skip = TRUE,
dir.out.pdf = paste0("files/pdf_tesseract_", name),
dir.out.txt = paste0("files/txt_tesseract_", name),
tempfile = TRUE,
quiet = TRUE,
jobs = tesseractJobs),
format = "file"),
tar_target(txt,
f.tar_pdf_extract(x = pdf,
outputdir = paste0("files/txt_", name),
multicore = config$parallel$extractPDF,
cores = fullCores),
format = "file"),
tar_target(dt,
f.readtext(x = txt,
docvarnames = docvarnames)),
tar_target(dt_ocr,
f.readtext(x = grep("\\.txt", ocr, value = TRUE),
docvarnames = docvarnames))
)
```
### Combine PDF Targets
```{targets tar.download.pdf}
tar_target(pdf_res_all,
c(pdf_res_ar,
pdf_res_en,
pdf_res_es,
pdf_res_fr,
pdf_res_ru,
pdf_res_zh),
format = "file")
```
### Combine TXT Targets
```{targets tar.download.txt}
tar_target(txt_all,
c(txt_res_en_gold,
txt_res_ar,
txt_res_en,
txt_res_es,
txt_res_fr,
txt_res_ru,
txt_res_zh,
txt_draft_en,
txt_meeting_en,
grep("\\.txt",c(ocr_res_ar,
ocr_res_en,
ocr_res_es,
ocr_res_fr,
ocr_res_ru,
ocr_res_zh,
ocr_draft_en,
ocr_meeting_en), value = TRUE)),
format = "file")
```
### Combine Extracted Resolution Text DT Targets
```{targets tar.download.dt.res.extracted}
tar_target(dt_extracted_res_all,
rbind(dt_res_ar,
dt_res_en,
dt_res_es,
dt_res_fr,
dt_res_ru,
dt_res_zh))
```
### Combine OCR Resolution Text DT Targets
```{targets tar.download.dt.res.ocr}
tar_target(dt_ocr_res_all,
rbind(dt_ocr_res_ar,
dt_ocr_res_en,
dt_ocr_res_es,
dt_ocr_res_fr,
dt_ocr_res_ru,
dt_ocr_res_zh))
```
### Combine Draft Text Table Targets
```{targets tar.download.dt.draft}
tar_target(dt_draft_all,
rbind(dt_draft_en,
dt_ocr_draft_en,
fill = TRUE))
```
### Combine Meeting Text Table Targets
```{targets tar.download.dt.meeting}
tar_target(dt_meeting_all,
rbind(dt_meeting_en,
dt_ocr_meeting_en,
fill = TRUE))
```
## Enhance Targets
### Merge Data
```{targets tar.enhance.merge}
tar_target(dt.intermediate,
f.merge_data(dt.extracted.res.all = dt_extracted_res_all,
dt.ocr.res.all = dt_ocr_res_all,
dt.res.en.gold = dt_res_en_gold,
dt.draft.all = dt_draft_all,
dt.meeting.all = dt_meeting_all,
dt.download.final = dt.download.final,
dt.record.final = dt.record.final,
dt.voting = dt.voting,
ocr.limit = 899))
```
### Create Variable \enquote{date}
```{targets tar.enhance.date}
tar_target(var_date,
f.date(dt.intermediate$title))
```
### Create Variables with REGEX Extraction from Resolution Text
```{targets tar.enhance.regex}
tar_target(var_regex,
f.regex_variables(dt.intermediate$text))
```
### Create Variables \enquote{ncharacters, ntokens, ntypes, nsentences}
Calculates a number of classical linguistic statistics.
```{targets tar.enhance.lingstats}
tar_target(var_lingstats,
f.lingstats(dt.intermediate,
multicore = config$parallel$lingsummarize,
cores = fullCores,
germanvars = FALSE))
```
### Create Constants
Creates a number of constants that contain important provenience information to be added to the data set. These are the version number, the version DOI, the concept DOI and the license. May become particularly relevant when merging individual rows from the data set with a larger data set.
```{targets tar.enhance.constants}
tar_target(var_constants,
data.frame(version = as.character(datestamp),
doi_concept = config$doi$data$concept,
doi_version = config$doi$data$version,
license = as.character(config$license$data))[rep(1, nrow(dt.intermediate)),])
```
### Combine Additional Variables
```{targets tar.enhance.combine}
tar_target(vars_additional,
data.table(date = var_date,
var_regex,
var_lingstats,
var_constants))
```
### Finalize Main Data Set
```{targets tar.enhance.finalize}
tar_target(dt.final,
f.finalize(dt.intermediate = dt.intermediate,
vars.additional = vars_additional,
varnames = dt.var_codebook$varname,
debug.toggle = config$debug$toggle))
```
### Create Variant: Metadata Only
Remove text variable to create a much smaller version of the data set with metadata only.
```{targets tar.variant.meta}
tar_target(dt.final.meta,
dt.final[, !c("text", "text_draft", "text_meeting")])
```
### Create Variant: Best TXT Files Only
```{targets tar.variant.txt.best}
tar_target(txt_en_best,
f.tar_write_txt(text = dt.final$text,
doc_id = dt.final$doc_id,
dir = "files/txt_res_en_best",
cleandir = TRUE))
```
## Citation Extraction
```{targets tar.citations}
tar_target(igraph_citations,
f.citation_extraction(dt.final = dt.final))
```
## Write Targets
Write finalized data sets and hash checksums to disk.
```{targets tar.write.csv}
values <- tibble::tibble(
name = c("final",
"meta"),
input = c(quote(dt.final),
quote(dt.final.meta)),
filename = paste0(prefix.files,
c("_ALL_CSV_FULL",
"_ALL_CSV_META"),
".csv")
)
csv.all <- tarchetypes::tar_map(unlist = FALSE,
values = values,
names = name,
tar_target(csv,
f.tar_fwrite(x = input,
filename = file.path("output",
filename)),
format = "file")
)
```
```{targets tar.write.graphs}
tar_target(graphml_citations,
f.tar_write_graph(graph = igraph_citations,
file = file.path("output",
paste0(prefix.files,
"_GraphML_Citations.graphml")),
format = "graphml"),
format = "file")
```
### Write Bibtex
```{targets tar.write.bibtex.oscola}
tar_target(bibtex.oscola,
f.bibtex(dt.final = dt.final,
filename = file.path("output",
paste0(prefix.files,
"_BIBTEX_OSCOLA.bib"))
)
)
```
## Report Targets
### Write \LaTeX Definitions
```{targets tar.report.defs}
tar_target(latexdefs,
f.latexdefs(config,
dir = "temp",
version = datestamp),
format = "file")