-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport_handler.R
More file actions
42 lines (39 loc) · 1.02 KB
/
export_handler.R
File metadata and controls
42 lines (39 loc) · 1.02 KB
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
# ------------------------------------------------------------------------------
# Export handling
output$downloadPlot <- downloadHandler(
filename = function(){
#paste0(input$file_in$name, 'zip')
outfile()
},
content = function(file) {
#ggsave(file,the_plot())
#go to a temp dir to avoid permission issues
owd <- setwd(tempdir())
on.exit(setwd(owd))
# Write out each file as selected by user
if(input$out2png){
png("out.png")
print(the_plot())
dev.off()
}
if(input$out2pdf){
pdf("out.pdf")
if(input$tagged){
pharmaTag(the_plot(), protocol = "ABC", population = "ITT")
}
else{
print(the_plot())
}
dev.off()
}
if(input$output_data){
readr::write_csv(data_in(), "out.csv")
}
# TODO: Add code and plot data
files <- c("out.png", "out.pdf", "out.csv")[c(input$out2png, input$out2pdf, input$output_data)]
#create the zip file
#if(!is.null(files)){
zip(file,files)
#}
}
)