-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunitedapp.R
348 lines (329 loc) · 22.2 KB
/
unitedapp.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
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
Sys.setlocale(,"UK_ua")
library(shiny)
library(shinydashboard)
library(tidyverse)
library(grid)
library(readxl)
library(rmarkdown)
library(gridExtra)
library(cowplot)
library(png)
library(extrafont)
unzip(".fonts.zip",exdir = "~/",overwrite = T)
system('fc-cache -f ~/.fonts')
ui <- dashboardPage(skin = "red",
title="Corestone work tools",
dashboardHeader(
title="Corestone work tools",
tags$li(class = "dropdown",
tags$a(href="http://corestone.expert/", target="_blank",
tags$img(height = "20px", alt="Corestone", src="http://corestone.expert/static/icons/ic-navbar-logo.svg")
)
),
dropdownMenuOutput("sys"),
tags$li(class = "dropdown",
tags$a(href = "https://github.com/RomanKyrychenko",
target = "_blank",
tags$img(height = "20px",
src = "https://raw.githubusercontent.com/oraza/sectarianviolencePK/master/www/github.png")
)
)
),
dashboardSidebar(
sidebarMenu(
menuItem("ІноЗМІ", tabName = "ІноЗМІ",icon = icon("newspaper-o")),
menuItem("Infoflow", tabName = "Infoflow", icon = icon("vcard-o")),
#menuItem("System", tabName = "sys2", icon = icon("line-chart")),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
hr(),
menuItem("Documentation", icon = icon("file-text-o"),
href = "https://github.com/RomanKyrychenko/digest/blob/master/README.md"),
menuItem("Feedback & suggestion", icon = icon("envelope-o"),
href = "mailto:?Roman.Kyrychenko@corestone.expert?subject=Feedback on Corestone work tools app"),
menuItem("Source code", icon = icon("file-code-o"),
href = "https://github.com/RomanKyrychenko/digest"),
menuItem("Fork me @ github", icon = icon("code-fork"),
href = "https://github.com/RomanKyrychenko")
)
),
dashboardBody(
tabItems(
tabItem(tabName = "ІноЗМІ",
h2("ІноЗМІ"),
fileInput("fl", "Excel",accept = c(".xlsx")),
downloadButton("digest", "Generate report")
),
tabItem(tabName = "Infoflow",
h2("Infoflow"),
fileInput('file1', 'Завантажте файл з даними',
accept = c(".xlsx")),
tags$hr(),
downloadButton('down',"Завантажити в pdf!"),
downloadButton('do',"Завантажити в png!"),
plotOutput('plot', width = "3666px", height = "2358px")
)#,
# tabItem(tabName = "sys2",
# h2("System"),
# actionButton("goButton", "Go!"),
# verbatimTextOutput("nText"))
)
)
)
server <- function(input,output,server,session){
df <- reactive({
inFile <- input$fl
if(is.null(inFile))
return(NULL)
file.rename(inFile$datapath,
paste(inFile$datapath, ".xlsx", sep=""))
data <-read_excel(paste(inFile$datapath, ".xlsx", sep=""),1,col_names = T)})
output$digest <- downloadHandler(
filename = "digest.pdf",
content = function(file) {
file.copy("digest_n.Rmd", "digest.Rmd", overwrite = T)
params <- list(data = df())
rmarkdown::render("digest.Rmd", output_file = file,
params = params,
envir = new.env(parent = globalenv())
)
}
)
df2 <- reactive({
inFile <- input$file1
if(is.null(inFile))
return(NULL)
file.rename(inFile$datapath,
paste(inFile$datapath, ".xlsx", sep=""))
data <- readxl::read_excel(paste(inFile$datapath, ".xlsx", sep=""),col_names = T)
infoflow <- function(data){
por <- c(9.9,8.85,7.8,6.75,5.7,4.65,3.6,2.55,1.5,.45)
lin <- inner_join(data_frame(name=data[[1]][14:23],tb=#c(10,8.85,7.7,6.9,5.87,4.83,3.78,2.73,1.68,.63)),
seq(10,0.1,-1.1)),
data_frame(name=data[[1]][2:11],net=#c(10,8.85,7.7,6.9,5.87,4.83,3.78,2.73,1.68,.63)),
seq(10,0.1,-1.1)),
by="name")
lin$tb2 <- 0
lin$net2 <- 1
p1 <- ggplot()+
geom_bar(aes(reorder(data[[1]][2:11],as.numeric(data[[2]][2:11])),
as.numeric(data[[3]][2:11])),stat = "identity",width = 0.6,fill="#DFE0E1",color=NA)+
geom_bar(aes(reorder(data[[1]][2:11],as.numeric(data[[2]][2:11])),
as.numeric(data[[2]][2:11])),stat = "identity",width = 0.4,fill="#A2C1C1",color=NA)+
geom_text(aes(reorder(data[[1]][2:11],as.numeric(data[[2]][2:11])),0,
label=reorder(data[[1]][2:11],as.numeric(data[[2]][2:11]))),hjust=0,vjust=-2,size=6*3,
family = "PT Sans")+
annotate("text",0.3,max(c(as.numeric(data[[2]][2:11]),as.numeric(data[[3]][2:11]))),label="тис. контактів",
hjust=1,vjust=-2,size=5*3,family = "PT Sans",color="#636566")+
ylab("")+
xlab("")+
scale_x_discrete(labels=rev(data[[1]][2:11]),position = "top")+
scale_y_continuous(expand = c(0, 0)) +
coord_flip() + theme(
panel.grid = element_blank(), panel.border = element_blank(),
axis.text.y = element_blank(),
axis.line.x = element_line(size=1,color="#A2C1C1"),
axis.line.y = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank(),
axis.text.x = element_text(hjust=0,vjust=-2,size=14*3,color="#636566",family = "PT Sans"),
axis.ticks.length = unit(0.1, "line"),
#axis.ticks.length = unit(-1, "line"),
plot.margin=unit(c(0,0,0,0), "cm")
)
p2 <- ggplot()+
geom_bar(aes(reorder(data[[1]][14:23],as.numeric(data[[2]][14:23])),
as.numeric(data[[3]][14:23])),stat = "identity",width = 0.6,fill="#DFE0E1")+
geom_bar(aes(reorder(data[[1]][14:23],as.numeric(data[[2]][14:23])),
as.numeric(data[[2]][14:23])),stat = "identity",width = 0.4,fill="#E1B5AC")+
geom_text(aes(reorder(data[[1]][14:23],as.numeric(data[[2]][14:23])),0,
label=reorder(data[[1]][14:23],as.numeric(data[[2]][14:23]))),hjust=1,vjust=-2,size=6*3,family = "PT Sans")+
annotate("text",0.3,max(c(as.numeric(data[[2]][14:23]),as.numeric(data[[3]][14:23]))),
label="млн контактів",hjust=0,vjust=-2,size=5*3,family = "PT Sans",color="#636566")+
ylab("")+
xlab("")+
scale_x_discrete(labels=rev(data[[1]][14:23]))+
coord_flip() + theme(
panel.grid = element_blank(), panel.border = element_blank(),
axis.line.x = element_line(color="#E1B5AC",size=1),
axis.ticks = element_blank(),
panel.background = element_blank(),
axis.line.y = element_blank(),
axis.text.y = element_blank(),
axis.text.x = element_text(hjust=1,vjust=-2,size=14*3,color="#636566",family = "PT Sans"),
axis.ticks.length = unit(0.1, "line"),
plot.margin=unit(c(0,0,0,0), "cm")
) + scale_y_reverse(expand = c(0, 0))
p3 <- ggplot() +
geom_segment(aes(x = lin$tb2, xend=lin$net2,y=lin$tb,yend=lin$net),color="#BFBFBF",alpha=1,size=0.5,lineend = "round") +
#scale_color_gradient(high="#136278",low="#c41e58")+
ylab("")+
xlab("")+
scale_x_continuous(limits = c(0,1),expand = c(0, 0))+
scale_y_continuous(limits = c(0,10))+
theme(
legend.position = "none",
panel.grid = element_blank(),
panel.border = element_blank(),
axis.line = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank(),
axis.text = element_blank(),
axis.ticks.length = unit(-1.4, "line"),
plot.margin=unit(c(0,-0.5,0,-0.5,0), "cm")
)
p4 <- ggplot()+
geom_text(aes(1,por,label=ifelse(!is.na(as.numeric(data[[4]][14:23])),paste0(round(as.numeric(data[[4]][14:23])*100),"%"),"∞")),family = "PT Sans",
hjust=1,color="#636566",size=6*3) +
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][14]>0,"green.png","red.png")), interpolate=TRUE), xmin=1, xmax=1.1, ymin=por[1]-0.1, ymax=por[1]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][15]>0,"green.png","red.png")), interpolate=TRUE), xmin=1, xmax=1.1, ymin=por[2]-0.1, ymax=por[2]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][16]>0,"green.png","red.png")), interpolate=TRUE), xmin=1, xmax=1.1, ymin=por[3]-0.1, ymax=por[3]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][17]>0,"green.png","red.png")), interpolate=TRUE), xmin=1, xmax=1.1, ymin=por[4]-0.1, ymax=por[4]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][18]>0,"green.png","red.png")), interpolate=TRUE), xmin=1, xmax=1.1, ymin=por[5]-0.1, ymax=por[5]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][19]>0,"green.png","red.png")), interpolate=TRUE), xmin=1, xmax=1.1, ymin=por[6]-0.1, ymax=por[6]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][20]>0,"green.png","red.png")), interpolate=TRUE), xmin=1, xmax=1.1, ymin=por[7]-0.1, ymax=por[7]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][21]>0,"green.png","red.png")), interpolate=TRUE), xmin=1, xmax=1.1, ymin=por[8]-0.1, ymax=por[8]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][22]>0,"green.png","red.png")), interpolate=TRUE), xmin=1, xmax=1.1, ymin=por[9]-0.1, ymax=por[9]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][23]>0,"green.png","red.png")), interpolate=TRUE), xmin=1, xmax=1.1, ymin=por[10]-0.1, ymax=por[10]+0.1)+
ylab("")+
xlab("")+
scale_x_continuous(limits = c(0.52,1.1))+
scale_y_continuous(limits = c(0,10.5),expand = c(0, 0))+
theme(
legend.position = "none",
panel.grid = element_blank(),
panel.border = element_blank(),
axis.line = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank(),
axis.text = element_blank(),
axis.ticks.length = unit(-1.4, "line"),
plot.margin=unit(c(0,0,0,0,0), "cm")
)
p5 <- grid.arrange(ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][2],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][2],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][3],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][3],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][4],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][4],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",gsub("ʹ","",stringi::stri_trans_general(data[[1]][5],"Ukrainian-Latin/BGN")),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",gsub("ʹ","",stringi::stri_trans_general(data[[1]][5],"Ukrainian-Latin/BGN")),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][6],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][6],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][7],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][7],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][8],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][8],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][9],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][9],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][10],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][10],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][11],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][11],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ncol=1)
p6 <- grid.arrange(ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][14],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][14],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][15],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][15],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][16],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][16],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",gsub("ʹ","",stringi::stri_trans_general(data[[1]][17],"Ukrainian-Latin/BGN")),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",gsub("ʹ","",stringi::stri_trans_general(data[[1]][17],"Ukrainian-Latin/BGN")),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][18],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][18],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][19],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][19],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][20],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][20],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][21],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][21],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][22],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][22],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ggplot() +
{if(file.exists(paste0("persons/",stringi::stri_trans_general(data[[1]][23],"Ukrainian-Latin/BGN"),".png")))annotation_custom(rasterGrob(readPNG(paste0("persons/",stringi::stri_trans_general(data[[1]][23],"Ukrainian-Latin/BGN"),".png")), interpolate=TRUE), xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)} +
geom_point(),ncol=1)
p7 <- ggplot()+
geom_text(aes(1,por,label=ifelse(!is.na(as.numeric(data[[4]][2:11])),paste0(round(as.numeric(data[[4]][2:11])*100),"%"),"∞")),family = "PT Sans",hjust=0,
color="#636566",size=6*3) +
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][2]>0,"green.png","red.png")), interpolate=TRUE), xmin=0.9, xmax=1, ymin=por[1]-0.1, ymax=por[1]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][3]>0,"green.png","red.png")), interpolate=TRUE), xmin=0.9, xmax=1, ymin=por[2]-0.1, ymax=por[2]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][4]>0,"green.png","red.png")), interpolate=TRUE), xmin=0.9, xmax=1, ymin=por[3]-0.1, ymax=por[3]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][5]>0,"green.png","red.png")), interpolate=TRUE), xmin=0.9, xmax=1, ymin=por[4]-0.1, ymax=por[4]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][6]>0,"green.png","red.png")), interpolate=TRUE), xmin=0.9, xmax=1, ymin=por[5]-0.1, ymax=por[5]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][7]>0,"green.png","red.png")), interpolate=TRUE), xmin=0.9, xmax=1, ymin=por[6]-0.1, ymax=por[6]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][8]>0,"green.png","red.png")), interpolate=TRUE), xmin=0.9, xmax=1, ymin=por[7]-0.1, ymax=por[7]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][9]>0,"green.png","red.png")), interpolate=TRUE), xmin=0.9, xmax=1, ymin=por[8]-0.1, ymax=por[8]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][10]>0,"green.png","red.png")), interpolate=TRUE), xmin=0.9, xmax=1, ymin=por[9]-0.1, ymax=por[9]+0.1)+
annotation_custom(rasterGrob(readPNG(ifelse(data[[4]][11]>0,"green.png","red.png")), interpolate=TRUE), xmin=0.9, xmax=1, ymin=por[10]-0.1, ymax=por[10]+0.1)+
ylab("")+
xlab("")+
scale_x_continuous(limits = c(0.9,1.52))+
scale_y_continuous(limits = c(0,10.5),expand = c(0, 0))+
theme(
legend.position = "none",
panel.grid = element_blank(),
panel.border = element_blank(),
axis.line = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank(),
axis.text = element_blank(),
axis.ticks.length = unit(-1.4, "line"),
plot.margin=unit(c(0,0,0,0,0), "cm")
)
grid.arrange(p2,p4,p6,p3,p5,p7,p1,ggplot(),
layout_matrix=cbind(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),
c(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,8),
c(3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,8),
c(4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,8),
c(5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,8),
c(6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,8),
c(7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7)),
widths=c(3,0.67,0.5,1,0.5,0.67,3))
}
infoflow(data)
})
output$plot <- renderPlot({
tryCatch(df2())
})
output$down <- downloadHandler(
filename = function(){
paste0("infoflow-",Sys.Date(),".pdf")
},
content = function(file) {
cairo_pdf(file, width=36.66*1.3, height=23.58*1.3,bg = "white")
grid.draw(df2())
dev.off()
}
)
output$do <- downloadHandler(
filename = function(){
paste0("infoflow-",Sys.Date(),".png")
},
content = function(file) {
png(file, width=3666, height=2358,bg = "white")
grid.draw(df2())
dev.off()
}
)
session$onSessionEnded(stopApp)
}
options(shiny.trace=TRUE)
shinyApp(ui,server)