-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_to_assess_data.R
77 lines (54 loc) · 2.23 KB
/
app_to_assess_data.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
library(shiny)
library(readxl)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("datain", "Upload WHIP Export", buttonLabel = "Choose file..."),
radioButtons('country', 'Select country',
choiceValues=c("Cambodia", "Lao PDR", "Vietnam"),
choiceNames = c('Cambodia', 'Laos', 'Viet nam'), inline = F),
downloadButton("report", "Assess data")
),
mainPanel("Download all the data from WHIP. Specifically, go to the quick search and click on the down arrow.
In 'Category', select 'Event', and in 'Field' select 'Event Code'. Type 'wcs' in 'Value' and click on
the green button on the upper-right corner.
Select all the sections in the export options and select 'Specimens' and 'Observation' as well.
Click on 'Export' and save the excel file.
Upload the excel file to the app, click on 'Assess data' and wait for some minutes (seriouly, just wait).
Open and download the .html output (Let me know if you have any problems).")
)
)
server <- function(input, output) {
# first open the observation and spec to get the number of columns
dataset<-reactive({
# inFile <- input$datain
dat<-read_excel(path =input$datain$datapath, sheet = 1, col_types = "text")
return(dat)
})
dataset2<-reactive({
# inFile <- input$datain
dat<-read_excel(path =input$datain$datapath, sheet = 2, col_types = "text")
return(dat)
})
output$report <- downloadHandler(
filename = "report.html",
content = function(file) {
report<-"assess_data.Rmd"
src <- normalizePath(report)
owd <- setwd(tempdir())
on.exit(setwd(owd))
file.copy(src, report, overwrite = TRUE)
spec <- dataset()
obs <- dataset2()
params <- list(spec = spec,
obs = obs,
country.of.interest=input$country)
out<-rmarkdown::render(report,
output_file = file,
params = params,
envir = new.env(parent = globalenv()))
file.rename(out, file)
}
)
}
shinyApp(ui, server)