This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an example app to understand how nested shiny modules are | |
# working and what is the general principle | |
library(shiny) | |
# Inner Module representing a widget | |
# that contains of UI rendered parts (text2) | |
# and server rendered parts (text1) | |
ui_inner <- function(id, text2) { | |
ns <- NS(id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# alpine-python-ecmwfapi | |
FROM rocker/tidyverse:3.6.0 | |
MAINTAINER zappingseb "sebastian@mail-wolf.de" | |
RUN R -e "install.packages(c('RSelenium'), repos='https://cran.rstudio.com/') " | |
RUN apt-get update -qq \ | |
&& apt-get install -y \ | |
python-pip \ | |
vim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create the dataset by merging the two tables per patient | |
data_set_reactive <- metaReactive({ | |
event_data_filtered <- event_data %>% dplyr::filter(PARAMCD == !!input$filter_param) | |
ads_selected <- pat_data %>% dplyr::select(dplyr::one_of(c(!!input$select_regressor, c("SUBJID", "STUDYID")))) | |
merge(ads_selected, event_data_filtered, by = c("SUBJID", "STUDYID")) | |
}) | |
# Create a pure reactive to create the formula shown in the linear model | |
formula_reactive <- reactive({ | |
validate(need(is.character(input$select_regressor), "Cannot work without selected column")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
observeEvent(input$show_r_code, { | |
showModal(modalDialog( | |
title = "R Code", | |
tags$pre( | |
id = "r_code", | |
expandChain( | |
library_code, | |
data_code, | |
output$plot1(), | |
output$text1() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plot Regression vs fitted | |
output$plot1 <- metaRender(renderPlot, { | |
plot(!!model_reactive(), which = 1) | |
}) | |
# show model summary | |
output$text1 <- metaRender(renderPrint, { | |
!!model_reactive() %>% summary() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a linear model | |
model_reactive <- metaReactive2({ | |
validate(need(is.data.frame(data_set_reactive()), "Data Set could not be created")) | |
validate(need(is.language(formula_reactive()), "Formula could not be created from column selections")) | |
metaExpr(bindToReturn = TRUE, { | |
model_data <- !!data_set_reactive() | |
lm(formula = !!formula_reactive(), data = model_data) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
formula_reactive <- reactive({ | |
validate(need(is.character(input$select_regressor), "Cannot work without selected column")) | |
regressors <- Reduce(function(x, y) call("+", x, y), rlang::syms(input$select_regressor)) | |
rlang::new_formula(rlang::sym("AVAL"), regressors) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data_set_reactive <- metaReactive({ | |
event_data_filtered <- event_data %>% dplyr::filter(PARAMCD == !!input$filter_param) | |
ads_selected <- pat_data %>% dplyr::select(dplyr::one_of(c(!!input$select_regressor, c("SUBJID", "STUDYID")))) | |
merge(ads_selected, event_data_filtered, by = c("SUBJID", "STUDYID")) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data_code <- quote({ | |
# Patient listing | |
pat_data <- ... | |
# Days where Overall Survival (OS), Event free survival (EFS) and Progression Free Survival (PFS) happened | |
event_data <- ... | |
}) | |
eval(data_code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a linear model | |
model_reactive <- reactive({ | |
validate(need(is.character(input$select_regressor), "Cannot work without selected column")) | |
regressors <- Reduce(function(x, y) call("+", x, y), rlang::syms(input$select_regressor)) | |
formula_value <- rlang::new_formula(rlang::sym("AVAL"), regressors) | |
event_data_filtered <- event_data %>% dplyr::filter(PARAMCD == input$filter_param) | |
ads_selected <- pat_data %>% dplyr::select(dplyr::one_of(c(input$select_regressor, c("SUBJID", "STUDYID")))) |
NewerOlder