• R/O
  • SSH

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョンcb6b3c288ba6e4ce099662f015333be3102eed2b (tree)
日時2021-02-24 00:06:41
作者Lorenzo Isella <lorenzo.isella@gmai...>
コミッターLorenzo Isella

ログメッセージ

I now generate a lot more tables with kableExtra.

変更サマリ

差分

diff -r e7b444ef5985 -r cb6b3c288ba6 R-codes/process_covid_tracker.R
--- a/R-codes/process_covid_tracker.R Tue Feb 23 10:04:57 2021 +0100
+++ b/R-codes/process_covid_tracker.R Tue Feb 23 16:06:41 2021 +0100
@@ -1,6 +1,6 @@
11 rm(list=ls())
22
3-## last saved on Time-stamp: "2021-02-22 20:38:46 lorenzo"
3+## last saved on Time-stamp: "2021-02-23 16:04:20 lorenzo"
44
55
66 library(tidyverse)
@@ -8,12 +8,32 @@
88 ## library(lubridate)
99 library(openxlsx)
1010 library(stringr)
11+library(formattable)
1112
1213 library(kableExtra)
1314
1415 ## source("/home/lorenzo/myprojects-hg/R-codes/stat_lib.R")
1516
1617
18+
19+##Function to be used independently
20+
21+wrapper2 <- function(x, width) {
22+ lapply(strwrap(x, width = width, simplify = FALSE), paste, collapse="\n")
23+
24+}
25+
26+
27+
28+wrapper_text <- function(x, width) {
29+ res <- wrapper2(x, width) %>% unlist %>%
30+ linebreak(align="l")
31+ return(res)
32+}
33+
34+
35+
36+
1737 format_col <- function(x, n, my_sep=" "){
1838
1939 res <- format(round(x, n), nsmall = n, big.mark= my_sep, trim=TRUE )
@@ -1073,39 +1093,18 @@
10731093 align="c")
10741094
10751095
1076-## pos <- which(t1_plot$partnerlabel %in% c("FTAs implemented",
1077-## "New generation of FTAs",
1078-## "DCFTAs" ,
1079-## "EPAs",
1080-## "FTAs concluded",
1081-## "FTAs future",
1082-## "First generation of FTAs",
1083-## "Others",
1084-## "Total extra EU27 trade") )
10851096
10861097 ll <- t1_plot %>%
10871098 search_replace( "%", "\\\\%" ) %>%
10881099 na_to_pattern(":") %>%
10891100 pattern_to_pattern("NA", ":") %>%
1090- ## pattern_to_pattern("NA\\%", "") %>%
1091- ## mutate(across(everything(),linebreak)) %>%
1092- ## mutate_all(linebreak) %>%
10931101 kable("latex", booktabs = T, escape = F,align=c("l", rep("r",11)),
10941102 col.names = nn,
10951103 caption = "EU Wide Statistics on Covid19 State Aid Measures"
1096- ## , linesep = c("\\addlinespace", "\\addlinespace", "","","","","","","\\addlinespace","", "",
1097- ## "","","","","","\\addlinespace","\\addlinespace",
1098- ## "\\addlinespace","\\addlinespace","","","","\\addlinespace","","","","","","","")
1099-
11001104 ) %>%
11011105 kable_styling(latex_options = c("striped", "hold_position"),
11021106 full_width = F## , font_size = 7
11031107 ) %>%
1104- ## add_indent(c(c(3,4,5,6,7,8,9,10,11,12,13,14,15,16, 17, 18, 19,20 ,22,23,24
1105- ## ,26,27,28,29,30,31,32
1106- ## ))) %>%
1107- ## add_header_above(c( "" , "Exports"=3,
1108- ## "Imports"=3, "Total trade"=3)) %>%
11091108 footnote(general=c(
11101109 "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE,
11111110 threeparttable = T) ## %>%
@@ -1134,118 +1133,895 @@
11341133 ll,
11351134 "\\end{document}"
11361135 ),
1137- "table.tex"
1136+ "table1.tex"
11381137 )
11391138
11401139
11411140
1142-tools::texi2pdf("table.tex", clean = TRUE)
1143-
1144-
1145-
1146-
1147-
1148-
1149-
1150-
1151-
1152-
1153-
1154-
1155-
1156-## t1_plot <- t1 %>%
1157-## search_replace( "%", "\\\\%" )
1158-
1159-
1160-
1161-
1162-## nn <- linebreak( c("Partners",
1163-## "Value", "Share in\nextra EU27", "Growth\n2018-2019",
1164-## "Value", "Share in\nextra EU27", "Growth\n2018-2019",
1165-## "Value", "Share in\nextra EU27", "Growth\n2018-2019") ,
1166-## align="c")
1167-
1168-
1169-## pos <- which(t1_plot$partnerlabel %in% c("FTAs implemented",
1170-## "New generation of FTAs",
1171-## "DCFTAs" ,
1172-## "EPAs",
1173-## "FTAs concluded",
1174-## "FTAs future",
1175-## "First generation of FTAs",
1176-## "Others",
1177-## "Total extra EU27 trade") )
1178-
1179-## ll <- t1_plot %>%
1180-## ## search_replace( "%", "\\\\%" ) %>%
1181-## na_to_pattern(":") %>%
1182-## pattern_to_pattern("NA", ":") %>%
1183-## ## pattern_to_pattern("NA\\%", "") %>%
1184-## mutate(across(everything(),linebreak)) %>%
1185-## ## mutate_all(linebreak) %>%
1186-## kable("latex", booktabs = T, escape = F,align=c("l", rep("r",11)),
1187-## col.names = nn,
1188-## caption = "EU27 trade in goods by FTA partner, 2019 (billion EUR, \\%)"
1189-## , linesep = c("\\addlinespace", "\\addlinespace", "","","","","","","\\addlinespace","", "",
1190-## "","","","","","\\addlinespace","\\addlinespace",
1191-## "\\addlinespace","\\addlinespace","","","","\\addlinespace","","","","","","","")
1192-
1193-## ) %>%
1194-## kable_styling(latex_options = c("striped", "hold_position"),
1195-## full_width = F## , font_size = 7
1196-## ) %>%
1197-## add_indent(c(c(3,4,5,6,7,8,9,10,11,12,13,14,15,16, 17, 18, 19,20 ,22,23,24
1198-## ,26,27,28,29,30,31,32
1199-## ))) %>%
1200-## add_header_above(c( "" , "Exports"=3,
1201-## "Imports"=3, "Total trade"=3)) %>%
1202-## footnote(general=c(
1203-## "\\\\textit{Source}: Eurostat (Comext)."),general_title = " ", escape = FALSE,
1204-## threeparttable = T) %>%
1205-## row_spec(pos, bold = T)
1206-
1207-
1208-
1209-
1210-
1211-## writeLines(
1212-## c(
1213-## "\\documentclass{article}",
1214-## "\\usepackage[a4paper, landscape]{geometry}",
1215-## "\\usepackage{helvet}",
1216-## "\\usepackage[flushleft]{threeparttable}" ,
1217-## "\\usepackage{graphicx}",
1218-## "\\renewcommand{\\familydefault}{\\sfdefault}",
1219-## "\\usepackage{caption}",
1220-## "\\usepackage[labelfont=bf,font=large]{caption}",
1221-## "\\usepackage{makecell}",
1222-## "\\usepackage{booktabs}",
1223-## "\\usepackage{colortbl, xcolor}",
1224-## "\\begin{document}",
1225-## "\\thispagestyle{empty}",
1226-## "\\captionsetup[table]{labelformat=empty, textfont=bf}",
1227-## ll,
1228-## "\\end{document}"
1229-## ),
1230-## "table45.tex"
1231-## )
1232-
1233-
1234-
1235-## tools::texi2pdf("table45.tex", clean = TRUE)
1236-
1237-
1238-
1239-
1240-
1241-
1242-
1243-
1244-
1245-
1246-
1247-
1248-
1141+tools::texi2pdf("table1.tex", clean = TRUE)
1142+
1143+###############################################################à
1144+###############################################################à
1145+###############################################################à
1146+###############################################################à
1147+
1148+
1149+## Another table
1150+
1151+t1 <- budget_type %>%
1152+ select(name, budget, share) %>%
1153+ mutate(share=share*100) %>%
1154+ mutate(budget=format_col(budget, 1),
1155+ share=format_col(share,2)) %>%
1156+ mutate(share=paste(share, "%", sep="")) %>%
1157+ pattern_to_pattern("-", "Total EU")
1158+
1159+
1160+
1161+
1162+
1163+nn <- linebreak( c("Case Type",
1164+ "Allocated Budget\n(Million EUR)", "Share of\nTotal"
1165+ ) ,
1166+ align="c")
1167+
1168+
1169+t1_plot <- t1
1170+
1171+ll <- t1_plot %>%
1172+ search_replace( "%", "\\\\%" ) %>%
1173+ na_to_pattern(":") %>%
1174+ pattern_to_pattern("NA", ":") %>%
1175+ kable("latex", booktabs = T, escape = F,align=c("l", rep("r",11)),
1176+ col.names = nn,
1177+ caption = "Covid19 Allocated Budget by Case Type (Decided Cases)"
1178+ ) %>%
1179+ kable_styling(latex_options = c("striped", "hold_position"),
1180+ full_width = F## , font_size = 7
1181+ ) %>%
1182+ footnote(general=c(
1183+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE,
1184+ threeparttable = T) ## %>%
1185+ ## row_spec(pos, bold = T)
1186+
1187+
1188+
1189+
1190+
1191+writeLines(
1192+ c(
1193+ "\\documentclass{article}",
1194+ "\\usepackage[a4paper]{geometry}",
1195+ "\\usepackage{helvet}",
1196+ "\\usepackage[flushleft]{threeparttable}" ,
1197+ "\\usepackage{graphicx}",
1198+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1199+ "\\usepackage{caption}",
1200+ "\\usepackage[labelfont=bf,font=large]{caption}",
1201+ "\\usepackage{makecell}",
1202+ "\\usepackage{booktabs}",
1203+"\\usepackage{colortbl, xcolor}",
1204+"\\begin{document}",
1205+"\\thispagestyle{empty}",
1206+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
1207+ ll,
1208+ "\\end{document}"
1209+ ),
1210+ "table2.tex"
1211+)
1212+
1213+
1214+
1215+tools::texi2pdf("table2.tex", clean = TRUE)
1216+
1217+
1218+
1219+######################################################
1220+######################################################
1221+######################################################
1222+
1223+
1224+## Another table
1225+
1226+t1 <- budget_measure %>%
1227+ arrange(desc(budget)) %>%
1228+ mutate(share=share*100) %>%
1229+ mutate(budget=format_col(budget, 1),
1230+ share=format_col(share,2)) %>%
1231+ mutate(share=paste(share, "%", sep="")) %>%
1232+ move_row(1, nrow(.)) %>%
1233+ mutate(type_of_measure=wrapper_text(type_of_measure,65))
1234+
1235+## t1 <- t1 %>%
1236+## bind_rows(t1)
1237+
1238+
1239+
1240+
1241+nn <- linebreak( c("Measure",
1242+ "Allocated Budget\n(Million EUR)", "Share of\nTotal"
1243+ ) ,
1244+ align="c")
1245+
1246+
1247+t1_plot <- t1
1248+
1249+ll <- t1_plot %>%
1250+ search_replace( "%", "\\\\%" ) %>%
1251+ search_replace( "&", "\\\\&" ) %>%
1252+ na_to_pattern(":") %>%
1253+ pattern_to_pattern("NA", ":") %>%
1254+
1255+ ## kable("latex",longtable = T, booktabs = T, escape = F,align=c("l", rep("r",6)),
1256+
1257+
1258+ kable("latex",longtable = T, booktabs = T, escape = F,align=c("l", rep("r",2)),
1259+ col.names = nn,
1260+ caption = "Covid19 Allocated Budget by Type of Measure (Decided Cases)"
1261+ ) %>%
1262+ kable_styling( position = "center",
1263+ latex_options = c("repeat_header","striped" , "hold_position"),
1264+ full_width = F) %>%
1265+ footnote(general=c(
1266+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE) ## %>%
1267+ ## row_spec(pos, bold = T)
1268+
1269+
1270+
1271+writeLines(
1272+ c(
1273+ "\\documentclass{article}",
1274+ "\\usepackage[a4paper]{geometry}",
1275+ "\\usepackage{longtable}",
1276+ "\\usepackage{helvet}",
1277+ "\\usepackage[flushleft]{threeparttable}" ,
1278+ "\\usepackage{graphicx}",
1279+ "\\usepackage{eurosym}",
1280+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1281+ "\\usepackage[justification=centering,labelfont=bf,font=large]{caption}",
1282+ "\\usepackage{makecell}",
1283+ "\\usepackage{booktabs}",
1284+"\\usepackage{colortbl, xcolor}",
1285+"\\begin{document}",
1286+"\\pagestyle{empty}",
1287+"\\setlength{\\LTleft}{-20cm plus -1fill}",
1288+"\\setlength{\\LTright}{\\LTleft}",
1289+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
1290+ ll,
1291+ "\\end{document}"
1292+ ),
1293+ "table3.tex"
1294+)
1295+
1296+
1297+
1298+tools::texi2pdf("table3.tex", clean = TRUE)
1299+
1300+
1301+
1302+
1303+#####################################################################
1304+#####################################################################
1305+#####################################################################
1306+
1307+
1308+t1 <- decisions_eu %>%
1309+ mutate(share=share*100) %>%
1310+ mutate(
1311+ share=format_col(share,2)) %>%
1312+ mutate(share=paste(share, "%", sep=""))
1313+
1314+
1315+
1316+nn <- linebreak( c("Legal Basis",
1317+ "Number of\nDecisions", "Share of\nTotal"
1318+ ) ,
1319+ align="c")
1320+
1321+
1322+t1_plot <- t1
1323+
1324+ll <- t1_plot %>%
1325+ search_replace( "%", "\\\\%" ) %>%
1326+ search_replace( "&", "\\\\&" ) %>%
1327+ na_to_pattern(":") %>%
1328+ pattern_to_pattern("NA", ":") %>%
1329+ pattern_to_pattern("NA", ":") %>%
1330+ kable("latex", booktabs = T, escape = F,align=c("l", rep("r",11)),
1331+ col.names = nn,
1332+ caption = "Covid19 Decisions by Legal Basis (Decided Cases)"
1333+ ) %>%
1334+ kable_styling(latex_options = c("striped", "hold_position"),
1335+ full_width = F## , font_size = 7
1336+ ) %>%
1337+ footnote(general=c(
1338+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE,
1339+ threeparttable = T) ## %>%
1340+ ## row_spec(pos, bold = T)
1341+
1342+
1343+
1344+
1345+
1346+writeLines(
1347+ c(
1348+ "\\documentclass{article}",
1349+ "\\usepackage[a4paper]{geometry}",
1350+ "\\usepackage{helvet}",
1351+ "\\usepackage[flushleft]{threeparttable}" ,
1352+ "\\usepackage{graphicx}",
1353+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1354+ "\\usepackage{caption}",
1355+ "\\usepackage[labelfont=bf,font=large]{caption}",
1356+ "\\usepackage{makecell}",
1357+ "\\usepackage{booktabs}",
1358+"\\usepackage{colortbl, xcolor}",
1359+"\\begin{document}",
1360+"\\thispagestyle{empty}",
1361+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
1362+ ll,
1363+ "\\end{document}"
1364+ ),
1365+ "table4.tex"
1366+)
1367+
1368+
1369+
1370+tools::texi2pdf("table4.tex", clean = TRUE)
1371+
1372+###########################################################################
1373+###########################################################################
1374+###########################################################################
1375+
1376+
1377+
1378+t1 <- measures_covid %>%
1379+ mutate(share=share*100) %>%
1380+ mutate(
1381+ share=format_col(share,2)) %>%
1382+ mutate(share=paste(share, "%", sep=""))
1383+
1384+
1385+
1386+nn <- linebreak( c("Legal Basis",
1387+ "Number of\nMeasures", "Share of\nTotal"
1388+ ) ,
1389+ align="c")
1390+
1391+
1392+t1_plot <- t1
1393+
1394+ll <- t1_plot %>%
1395+ search_replace( "%", "\\\\%" ) %>%
1396+ search_replace( "&", "\\\\&" ) %>%
1397+ na_to_pattern(":") %>%
1398+ pattern_to_pattern("NA", ":") %>%
1399+ pattern_to_pattern("NA", ":") %>%
1400+ kable("latex", booktabs = T, escape = F,align=c("l", rep("r",11)),
1401+ col.names = nn,
1402+ caption = "Covid19 Measures by Legal Basis (Decided Cases)"
1403+ ) %>%
1404+ kable_styling(latex_options = c("striped", "hold_position"),
1405+ full_width = F## , font_size = 7
1406+ ) %>%
1407+ footnote(general=c(
1408+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE,
1409+ threeparttable = T) ## %>%
1410+ ## row_spec(pos, bold = T)
1411+
1412+
1413+
1414+
1415+
1416+writeLines(
1417+ c(
1418+ "\\documentclass{article}",
1419+ "\\usepackage[a4paper]{geometry}",
1420+ "\\usepackage{helvet}",
1421+ "\\usepackage[flushleft]{threeparttable}" ,
1422+ "\\usepackage{graphicx}",
1423+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1424+ "\\usepackage{caption}",
1425+ "\\usepackage[labelfont=bf,font=large]{caption}",
1426+ "\\usepackage{makecell}",
1427+ "\\usepackage{booktabs}",
1428+"\\usepackage{colortbl, xcolor}",
1429+"\\begin{document}",
1430+"\\thispagestyle{empty}",
1431+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
1432+ ll,
1433+ "\\end{document}"
1434+ ),
1435+ "table5.tex"
1436+)
1437+
1438+
1439+
1440+tools::texi2pdf("table5.tex", clean = TRUE)
1441+
1442+
1443+######################################################################
1444+######################################################################
1445+######################################################################
1446+######################################################################
1447+
1448+
1449+temp <- tibble(x=c("NO", "YES", "Total"), name=c("Under assessment", "Decided cases", "Total"))
1450+
1451+t1 <- sa_n_pn %>%
1452+ left_join(y=temp, by=c("decided"="x")) %>%
1453+ select(name, nn, share)%>%
1454+ mutate(share=share*100) %>%
1455+ mutate(
1456+ share=format_col(share,2)) %>%
1457+ mutate(share=paste(share, "%", sep=""))
1458+
1459+
1460+
1461+nn <- linebreak( c("Case Assessment Status",
1462+ "Number of\nCases", "Share of\nTotal"
1463+ ) ,
1464+ align="c")
1465+
1466+
1467+t1_plot <- t1
1468+
1469+ll <- t1_plot %>%
1470+ search_replace( "%", "\\\\%" ) %>%
1471+ search_replace( "&", "\\\\&" ) %>%
1472+ na_to_pattern(":") %>%
1473+ pattern_to_pattern("NA", ":") %>%
1474+ pattern_to_pattern("NA", ":") %>%
1475+ kable("latex", booktabs = T, escape = F,align=c("l", rep("r",11)),
1476+ col.names = nn,
1477+ caption = "SA Case Assessment Pipeline\\\\Overview N and PN Cases"
1478+ ) %>%
1479+ kable_styling(latex_options = c("striped", "hold_position"),
1480+ full_width = F## , font_size = 7
1481+ ) %>%
1482+ footnote(general=c(
1483+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE,
1484+ threeparttable = T) ## %>%
1485+ ## row_spec(pos, bold = T)
1486+
1487+
1488+
1489+
1490+
1491+writeLines(
1492+ c(
1493+ "\\documentclass{article}",
1494+ "\\usepackage[a4paper]{geometry}",
1495+ "\\usepackage{helvet}",
1496+ "\\usepackage[flushleft]{threeparttable}" ,
1497+ "\\usepackage{graphicx}",
1498+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1499+ "\\usepackage{caption}",
1500+ "\\usepackage[labelfont=bf,font=large]{caption}",
1501+ "\\usepackage{makecell}",
1502+ "\\usepackage{booktabs}",
1503+"\\usepackage{colortbl, xcolor}",
1504+"\\begin{document}",
1505+"\\thispagestyle{empty}",
1506+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
1507+ ll,
1508+ "\\end{document}"
1509+ ),
1510+ "table6.tex"
1511+)
1512+
1513+
1514+
1515+tools::texi2pdf("table6.tex", clean = TRUE)
1516+
1517+#######################################################################
1518+#######################################################################
1519+#######################################################################
1520+#######################################################################
1521+
1522+
1523+
1524+
1525+t1 <- sa_n_pn_unit %>%
1526+ ## left_join(y=temp, by=c("decided"="x")) %>%
1527+ ## select(name, nn, share)%>%
1528+ mutate(share=share*100) %>%
1529+ mutate(
1530+ share=format_col(share,2)) %>%
1531+ mutate(share=paste(share, "%", sep=""))
1532+
1533+
1534+
1535+nn <- linebreak( c("Responsible Unit",
1536+ "Number of\nCases", "Share of\nTotal"
1537+ ) ,
1538+ align="c")
1539+
1540+
1541+t1_plot <- t1
1542+
1543+ll <- t1_plot %>%
1544+ search_replace( "%", "\\\\%" ) %>%
1545+ search_replace( "&", "\\\\&" ) %>%
1546+ na_to_pattern(":") %>%
1547+ pattern_to_pattern("NA", ":") %>%
1548+ pattern_to_pattern("NA", ":") %>%
1549+ kable("latex", booktabs = T, escape = F,align=c("l", rep("r",11)),
1550+ col.names = nn,
1551+ caption = "SA Case Assessment Pipeline\\\\Overview N and PN Cases"
1552+ ) %>%
1553+ kable_styling(latex_options = c("striped", "hold_position"),
1554+ full_width = F## , font_size = 7
1555+ ) %>%
1556+ footnote(general=c(
1557+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE,
1558+ threeparttable = T) ## %>%
1559+ ## row_spec(pos, bold = T)
1560+
1561+
1562+
1563+
1564+
1565+writeLines(
1566+ c(
1567+ "\\documentclass{article}",
1568+ "\\usepackage[a4paper]{geometry}",
1569+ "\\usepackage{helvet}",
1570+ "\\usepackage[flushleft]{threeparttable}" ,
1571+ "\\usepackage{graphicx}",
1572+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1573+ "\\usepackage{caption}",
1574+ "\\usepackage[labelfont=bf,font=large]{caption}",
1575+ "\\usepackage{makecell}",
1576+ "\\usepackage{booktabs}",
1577+"\\usepackage{colortbl, xcolor}",
1578+"\\begin{document}",
1579+"\\thispagestyle{empty}",
1580+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
1581+ ll,
1582+ "\\end{document}"
1583+ ),
1584+ "table7.tex"
1585+)
1586+
1587+
1588+
1589+tools::texi2pdf("table7.tex", clean = TRUE)
1590+
1591+
1592+
1593+
1594+
1595+#######################################################################
1596+#######################################################################
1597+#######################################################################
1598+#######################################################################
1599+
1600+
1601+t1 <- budget_by_beneficiary_sector %>%
1602+ mutate(share=share*100) %>%
1603+ mutate(
1604+ share=format_col(share,2)) %>%
1605+ mutate(share=paste(share, "%", sep="")) %>%
1606+ mutate(budget=format_col(budget,1))
1607+
1608+
1609+
1610+
1611+
1612+
1613+
1614+
1615+nn <- linebreak( c("Sector",
1616+ "Allocated Budget\n(Million EUR)", "Share of\nTotal"
1617+ ) ,
1618+ align="c")
1619+
1620+
1621+t1_plot <- t1
1622+
1623+ll <- t1_plot %>%
1624+ search_replace( "%", "\\\\%" ) %>%
1625+ search_replace( "&", "\\\\&" ) %>%
1626+ na_to_pattern(":") %>%
1627+ pattern_to_pattern("NA", ":") %>%
1628+ pattern_to_pattern("NA", ":") %>%
1629+ kable("latex",longtable = T, booktabs = T, escape = F,align=c("l", rep("r",11)),
1630+ col.names = nn,
1631+ caption = "Covid19 Allocated Budget by Sector"
1632+ ) %>%
1633+ kable_styling(latex_options = c("striped", "hold_position"),
1634+ full_width = F## , font_size = 7
1635+ ) %>%
1636+ footnote(general=c(
1637+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE## ,
1638+ ## threeparttable = T
1639+ ) ## %>%
1640+ ## row_spec(pos, bold = T)
1641+
1642+
1643+
1644+
1645+
1646+writeLines(
1647+ c(
1648+ "\\documentclass{article}",
1649+ "\\usepackage[a4paper]{geometry}",
1650+ "\\usepackage{longtable}",
1651+ "\\usepackage{helvet}",
1652+ "\\usepackage[flushleft]{threeparttable}" ,
1653+ "\\usepackage{graphicx}",
1654+ "\\usepackage{eurosym}",
1655+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1656+ "\\usepackage[justification=centering,labelfont=bf,font=large]{caption}",
1657+ "\\usepackage{makecell}",
1658+ "\\usepackage{booktabs}",
1659+"\\usepackage{colortbl, xcolor}",
1660+"\\begin{document}",
1661+"\\pagestyle{empty}",
1662+"\\setlength{\\LTleft}{-20cm plus -1fill}",
1663+"\\setlength{\\LTright}{\\LTleft}",
1664+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
1665+ ll,
1666+ "\\end{document}"
1667+ ),
1668+ "table8.tex"
1669+)
1670+
1671+
1672+
1673+
1674+
1675+
1676+
1677+tools::texi2pdf("table8.tex", clean = TRUE)
1678+
1679+
1680+##################################################################
1681+##################################################################
1682+##################################################################
1683+##################################################################
1684+
1685+
1686+
1687+t1 <- budget_by_beneficiary_type %>%
1688+ mutate(share=share*100) %>%
1689+ mutate(
1690+ share=format_col(share,2)) %>%
1691+ mutate(share=paste(share, "%", sep="")) %>%
1692+ mutate(budget=format_col(budget,1))
1693+
1694+
1695+
1696+
1697+
1698+
1699+
1700+
1701+
1702+
1703+nn <- linebreak( c("Beneficiary",
1704+ "Allocated Budget\n(Million EUR)", "Share of\nTotal"
1705+ ) ,
1706+ align="c")
1707+
1708+
1709+t1_plot <- t1
1710+
1711+ll <- t1_plot %>%
1712+ search_replace( "%", "\\\\%" ) %>%
1713+ search_replace( "&", "\\\\&" ) %>%
1714+ na_to_pattern(":") %>%
1715+ pattern_to_pattern("NA", ":") %>%
1716+ pattern_to_pattern("NA", ":") %>%
1717+ kable("latex", booktabs = T, escape = F,align=c("l", rep("r",11)),
1718+ col.names = nn,
1719+ caption = "Covid19 Allocated Budget by Type of Beneficiary"
1720+ ) %>%
1721+ kable_styling(latex_options = c("striped", "hold_position"),
1722+ full_width = F## , font_size = 7
1723+ ) %>%
1724+ footnote(general=c(
1725+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE,
1726+ threeparttable = T
1727+ ) ## %>%
1728+ ## row_spec(pos, bold = T)
1729+
1730+
1731+
1732+
1733+
1734+writeLines(
1735+ c(
1736+ "\\documentclass{article}",
1737+ "\\usepackage[a4paper]{geometry}",
1738+ "\\usepackage{longtable}",
1739+ "\\usepackage{helvet}",
1740+ "\\usepackage[flushleft]{threeparttable}" ,
1741+ "\\usepackage{graphicx}",
1742+ "\\usepackage{eurosym}",
1743+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1744+ "\\usepackage[justification=centering,labelfont=bf,font=large]{caption}",
1745+ "\\usepackage{makecell}",
1746+ "\\usepackage{booktabs}",
1747+"\\usepackage{colortbl, xcolor}",
1748+"\\begin{document}",
1749+"\\pagestyle{empty}",
1750+"\\setlength{\\LTleft}{-20cm plus -1fill}",
1751+"\\setlength{\\LTright}{\\LTleft}",
1752+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
1753+ ll,
1754+ "\\end{document}"
1755+ ),
1756+ "table9.tex"
1757+)
1758+
1759+
1760+
1761+
1762+
1763+
1764+
1765+tools::texi2pdf("table9.tex", clean = TRUE)
1766+
1767+##############################################################à
1768+##############################################################à
1769+##############################################################à
1770+##############################################################à
1771+##############################################################à
1772+
1773+
1774+t1 <- duration_stat_basis %>%
1775+ select(legal_basis, mean_duration) %>%
1776+ mutate(mean_duration=format_col(mean_duration, 1))
1777+
1778+
1779+
1780+
1781+nn <- linebreak( c("Legal Basis",
1782+ "Number of Days"
1783+ ) ,
1784+ align="c")
1785+
1786+
1787+t1_plot <- t1
1788+
1789+ll <- t1_plot %>%
1790+ search_replace( "%", "\\\\%" ) %>%
1791+ search_replace( "&", "\\\\&" ) %>%
1792+ na_to_pattern(":") %>%
1793+ pattern_to_pattern("NA", ":") %>%
1794+ pattern_to_pattern("NA", ":") %>%
1795+ kable("latex", booktabs = T, escape = F,align=c("l", rep("r",11)),
1796+ col.names = nn,
1797+ caption = "Average Number of Days to Process a Decision\\\\by Legal Basis"
1798+ ) %>%
1799+ kable_styling(latex_options = c("striped", "hold_position"),
1800+ full_width = F## , font_size = 7
1801+ ) %>%
1802+ footnote(general=c(
1803+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE,
1804+ threeparttable = T
1805+ ) ## %>%
1806+ ## row_spec(pos, bold = T)
1807+
1808+
1809+
1810+
1811+
1812+writeLines(
1813+ c(
1814+ "\\documentclass{article}",
1815+ "\\usepackage[a4paper]{geometry}",
1816+ "\\usepackage{longtable}",
1817+ "\\usepackage{helvet}",
1818+ "\\usepackage[flushleft]{threeparttable}" ,
1819+ "\\usepackage{graphicx}",
1820+ "\\usepackage{eurosym}",
1821+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1822+ "\\usepackage[justification=centering,labelfont=bf,font=large]{caption}",
1823+ "\\usepackage{makecell}",
1824+ "\\usepackage{booktabs}",
1825+"\\usepackage{colortbl, xcolor}",
1826+"\\begin{document}",
1827+"\\pagestyle{empty}",
1828+"\\setlength{\\LTleft}{-20cm plus -1fill}",
1829+"\\setlength{\\LTright}{\\LTleft}",
1830+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
1831+ ll,
1832+ "\\end{document}"
1833+ ),
1834+ "table10.tex"
1835+)
1836+
1837+
1838+
1839+
1840+
1841+
1842+
1843+tools::texi2pdf("table10.tex", clean = TRUE)
1844+
1845+############################################################à
1846+############################################################à
1847+############################################################à
1848+############################################################à
1849+
1850+
1851+
1852+
1853+
1854+t1 <- duration_stat_measure %>%
1855+ select(type_of_measure, mean_duration) %>%
1856+ mutate(mean_duration=format_col(mean_duration, 1))%>%
1857+ mutate(type_of_measure=wrapper_text(type_of_measure,65))
1858+
1859+
1860+
1861+nn <- linebreak( c("Type of Measure",
1862+ "Number of Days"
1863+ ) ,
1864+ align="c")
1865+
1866+
1867+t1_plot <- t1
1868+
1869+ll <- t1_plot %>%
1870+ search_replace( "%", "\\\\%" ) %>%
1871+ search_replace( "&", "\\\\&" ) %>%
1872+ na_to_pattern(":") %>%
1873+ pattern_to_pattern("NA", ":") %>%
1874+
1875+ ## kable("latex",longtable = T, booktabs = T, escape = F,align=c("l", rep("r",6)),
1876+
1877+
1878+ kable("latex",longtable = T, booktabs = T, escape = F,align=c("l", rep("r",2)),
1879+ col.names = nn,
1880+ caption = "Average Number of Days to Process a Decision\\\\by Legal Basis"
1881+ ) %>%
1882+ kable_styling( position = "center",
1883+ latex_options = c("repeat_header","striped" , "hold_position"),
1884+ full_width = F) %>%
1885+ footnote(general=c(
1886+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE) ## %>%
1887+ ## row_spec(pos, bold = T)
1888+
1889+
1890+
1891+writeLines(
1892+ c(
1893+ "\\documentclass{article}",
1894+ "\\usepackage[a4paper]{geometry}",
1895+ "\\usepackage{longtable}",
1896+ "\\usepackage{helvet}",
1897+ "\\usepackage[flushleft]{threeparttable}" ,
1898+ "\\usepackage{graphicx}",
1899+ "\\usepackage{eurosym}",
1900+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1901+ "\\usepackage[justification=centering,labelfont=bf,font=large]{caption}",
1902+ "\\usepackage{makecell}",
1903+ "\\usepackage{booktabs}",
1904+"\\usepackage{colortbl, xcolor}",
1905+"\\begin{document}",
1906+"\\pagestyle{empty}",
1907+"\\setlength{\\LTleft}{-20cm plus -1fill}",
1908+"\\setlength{\\LTright}{\\LTleft}",
1909+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
1910+ ll,
1911+ "\\end{document}"
1912+ ),
1913+ "table11.tex"
1914+)
1915+
1916+
1917+
1918+tools::texi2pdf("table11.tex", clean = TRUE)
1919+
1920+###################################################################
1921+###################################################################
1922+###################################################################
1923+###################################################################
1924+
1925+
1926+
1927+temp <- tibble(x=c("TF1", "TF2", "TF3", "TF6", "TF7", "TF8", "TF9",
1928+ "TF10", "TF11", "TF12", "Total"),
1929+ name=c("3.1 Limited amount of aid", "3.2 Aid in the form of guarantees on loans", "3.3 Aid in the form of subsidised interest rates for loans",
1930+ "3.6 Aid for COVID-19 relevant research and development",
1931+ "3.7 Investment aid for testing and upscaling infrastructures",
1932+ "3.8 Investment aid for the production of COVID-19 relevant products",
1933+ "3.9 Aid in form of deferrals of tax and or social security contributions",
1934+ "3.10 Aid in form of wage subsidies for employees to avoid lay-offs during the COVID-19 outbreak",
1935+ "3.11 Recapitalisation measures for non-financial undertakings",
1936+ "3.12 Support for uncovered fixed costs",
1937+ "Total")
1938+
1939+ )
1940+
1941+
1942+
1943+
1944+t1 <- chapters_stat_fin %>%
1945+ left_join(y=temp, by=c("TF_chapter"="x")) %>%
1946+ select(name, value, share) %>%
1947+ mutate(share=share*100) %>%
1948+ mutate(
1949+ share=format_col(share,2)) %>%
1950+ mutate(share=paste(share, "%", sep="")) %>%
1951+ mutate(name=wrapper_text(name, 65))
1952+
1953+nn <- linebreak( c("Chapter Description",
1954+ "Frequency", "Share of\nTotal"
1955+ ) ,
1956+ align="c")
1957+
1958+
1959+t1_plot <- t1
1960+
1961+ll <- t1_plot %>%
1962+ search_replace( "%", "\\\\%" ) %>%
1963+ search_replace( "&", "\\\\&" ) %>%
1964+ na_to_pattern(":") %>%
1965+ pattern_to_pattern("NA", ":") %>%
1966+ pattern_to_pattern("NA", ":") %>%
1967+ kable("latex", booktabs = T, escape = F,align=c("l", rep("r",11)),
1968+ col.names = nn,
1969+ caption = "Frequency of Use of Temporary Framework Chapters"
1970+ ) %>%
1971+ kable_styling(latex_options = c("striped", "hold_position"),
1972+ full_width = F## , font_size = 7
1973+ ) %>%
1974+ footnote(general=c(
1975+ "\\\\textit{Source}: ISIS Database."),general_title = " ", escape = FALSE,
1976+ threeparttable = T
1977+ ) ## %>%
1978+ ## row_spec(pos, bold = T)
1979+
1980+
1981+
1982+
1983+
1984+writeLines(
1985+ c(
1986+ "\\documentclass{article}",
1987+ "\\usepackage[a4paper]{geometry}",
1988+ "\\usepackage{longtable}",
1989+ "\\usepackage{helvet}",
1990+ "\\usepackage[flushleft]{threeparttable}" ,
1991+ "\\usepackage{graphicx}",
1992+ "\\usepackage{eurosym}",
1993+ "\\renewcommand{\\familydefault}{\\sfdefault}",
1994+ "\\usepackage[justification=centering,labelfont=bf,font=large]{caption}",
1995+ "\\usepackage{makecell}",
1996+ "\\usepackage{booktabs}",
1997+"\\usepackage{colortbl, xcolor}",
1998+"\\begin{document}",
1999+"\\pagestyle{empty}",
2000+"\\setlength{\\LTleft}{-20cm plus -1fill}",
2001+"\\setlength{\\LTright}{\\LTleft}",
2002+"\\captionsetup[table]{labelformat=empty, textfont=bf}",
2003+ ll,
2004+ "\\end{document}"
2005+ ),
2006+ "table12.tex"
2007+)
2008+
2009+
2010+
2011+
2012+
2013+
2014+
2015+tools::texi2pdf("table12.tex", clean = TRUE)
2016+
2017+
2018+
2019+
2020+
2021+
2022+###join all the docs
2023+
2024+system("pdftk table1.pdf table2.pdf table3.pdf table4.pdf table5.pdf table6.pdf table7.pdf table8.pdf table9.pdf table10.pdf table11.pdf table12.pdf cat output assembled.pdf " )
12492025
12502026
12512027