launch_app.R 3.51 KB
Newer Older
1
2
# DQAgui - A graphical user interface (GUI) to the functions implemented in the
# R package 'DQAstats'.
3
# Copyright (C) 2019-2022 Universitätsklinikum Erlangen
Lorenz Kapsner's avatar
Lorenz Kapsner committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#
# 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 <http://www.gnu.org/licenses/>.

18

kapsner's avatar
kapsner committed
19
20
#' @title Launch the DQA graphical user interface (GUI)
#'
21
#' @param port The port, the MIRACUM DQA Tool is running on (default: 3838)
Jonathan Mang's avatar
Jonathan Mang committed
22
#' @param utils_path The path to the utilities-folder, containing the metadata
23
24
25
26
#'   repository files (`mdr.csv` inside the folder `MDR`), JSON files with SQL
#'   statements (inside the folder `SQL`), config files for the database
#'   connection (`settings_default.yml`) and the email address used for the
#'   data map (`email.yml`), a JSON file containing site names (inside the
27
#'   folder `MISC`) and a markdown template to create the PDF report
28
#'   (`DQA_report.Rmd` inside the folder `RMD`).
29
#' @param mdr_filename The filename of the mdr (e.g. "mdr_example_data.csv").
30
31
#' @param logfile_dir Is the absolute path to the directory where the logfile
#'   will be stored. If not path is provided the tempdir() will be used.
32
33
34
35
36
#' @param parallel A boolean. If TRUE (the default value), initializing
#'   `future::plan("multiprocess")` before running the code.
#' @param ncores A integer. The number of cores to use. Caution: you would
#'   probably like to choose a low number when operating on large datasets.
#'   Default: 2.
kapsner's avatar
kapsner committed
37
#'
38
#' @return Executing this function returns a DQAgui shiny application.
kapsner's avatar
kapsner committed
39
40
41
42
43
#'
#' @import shiny shinydashboard
#' @importFrom magrittr "%>%"
#' @importFrom data.table .N ":="
#'
44
45
46
47
#' @examples
#' if (interactive()) {
#'   launch_app()
#' }
kapsner's avatar
kapsner committed
48
#'
49
#' @export
kapsner's avatar
kapsner committed
50

51
52
53
launch_app <- function(port = 3838,
                       utils_path = system.file("demo_data/utilities",
                                                package = "DQAstats"),
54
                       mdr_filename = "mdr_example_data.csv",
55
56
57
                       logfile_dir = tempdir(),
                       parallel = TRUE,
                       ncores = 2) {
58

59
  DIZtools::assign_to_R_env(key = "utils_path",
60
61
                            val = utils_path,
                            pos = 1L)
62

63
  DIZtools::assign_to_R_env(key = "mdr_filename",
64
65
                            val = mdr_filename,
                            pos = 1L)
66

67
  DIZtools::assign_to_R_env(key = "logfile_dir",
68
69
                            val = logfile_dir,
                            pos = 1L)
70

71
  DIZtools::assign_to_R_env(key = "parallel",
72
73
74
                            val = parallel,
                            pos = 1L)

75
  DIZtools::assign_to_R_env(key = "ncores",
76
77
78
                            val = ncores,
                            pos = 1L)

kapsner's avatar
kapsner committed
79
  options(shiny.port = port)
80

Lorenz Kapsner's avatar
Lorenz Kapsner committed
81
82
83
84
85
86
87
88
89
  message(
    paste0(
      "\nVersion DIZutils: ", utils::packageVersion("DIZutils"),
      "\nVersion DQAstats: ", utils::packageVersion("DQAstats"),
      "\nVersion DQAgui: ", utils::packageVersion("DQAgui"),
      "\n"
    )
  )

90
91
92
  shiny::shinyAppDir(
    appDir = system.file("application", package = "DQAgui")
  )
kapsner's avatar
kapsner committed
93
}