Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
## ##
## CALIBRATOR ##
## ##
message("* Loading libraries *")
library(magrittr)
library(tidyverse)
library(shiny)
library(shinythemes)
library(foreach)
library(openxlsx)
library(gplots)
library(enviPat)
dir1 <- "Scripts"
message("* Loading scripts *")
CUTOFF_RANGE <<-
list(
min = 0.2,
max = 1,
step = 0.05,
values = seq(0.2, 1, .05)
)
for (f in list.files(dir1, pattern = "\\.R$")) {
source(file.path(dir1, f))
}
if (Sys.info()["user"] == "cedlich") {
assign("DEBUG", TRUE, env = .GlobalEnv)
} else {
assign("DEBUG", FALSE, env = .GlobalEnv)
}
message("* Assigning global variables *")
assign("MY_SHINY_PREFERENCES",
if(file.exists("shiny_preferences.RDS")) my_read_shiny_prefs() else list(),
envir = .GlobalEnv
)
data("isotopes")
assign("colours1", colours() %>% keep(!grepl("^gr[ea]y", .) & !grepl("[0-9]$", .)) %>% sort(), envir = .GlobalEnv)
message("* Starting shiny *")
#### ui ####
ui <-
fluidPage(
# titlePanel("CalibraShiny"),
navbarPage(
title = "Shiny Calibration",
tabPanel("Infile", source(file.path("ui_code", "0100_ui_infile.R"), local = TRUE)$value),
tabPanel("Plotter", source(file.path("ui_code", "0200_ui_fitter.R"), local = TRUE)$value),
tabPanel("Outfile", source(file.path("ui_code", "0300_ui_outfile.R"), local = TRUE)$value)
)
)
server <- function(input, output, session) {
my_plot <- reactiveValues()
my_raw_data <- reactiveValues()
my_data <- reactiveValues()
source(file.path("server_code", "0100_server_infile.R"), local = TRUE)$value
source(file.path("server_code", "0200_server_plot.R"), local = TRUE)$value
source(file.path("server_code", "0300_server_outfile.R"), local = TRUE)$value
onStop(function() {
env = parent.env(environment())
ls(envir = env) %>%
## .. excluding e.g. session" and "output"
setdiff(c("session", "output", "my_pref_update")) %>%
## object in a list
mget(envir = env) %>%
## keep only reactive values
subset(., subset = sapply(., is.reactivevalues)) %>%
## convert reactive values
sapply(function(z) isolate(reactiveValuesToList(z)), simplify=F) %>%
## assign to global environment
list2env(envir = .GlobalEnv)
cat("Session stopped\n")
cat("Type `save(list=ls(), file='tmp.RData')` to save state variables in your current working directory\n")
cat("Find out what current working directory by typing `getwd()`\n")
})
}
shinyApp(ui, server)