Skip to content

Commit

Permalink
extended docu for formula editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad1991 committed Nov 7, 2024
1 parent 7b0e0a1 commit 143d487
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 4,436 deletions.
15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rocker/shiny:4.3.1
FROM rocker/shiny:4.4.2

RUN apt-get update && apt-get install -y \
--no-install-recommends \
Expand All @@ -17,14 +17,10 @@ ENV SHINY_LOG_STDERR=1

RUN install2.r --error --skipinstalled \
shiny \
shinydashboard \
shinyWidgets \
shinyjs \
forecast \
jsonlite \
ggplot2 \
htmltools \
plotly \
drc \
DT \
httr \
Expand All @@ -33,7 +29,6 @@ RUN install2.r --error --skipinstalled \
readxl \
openxlsx \
purrr \
pheatmap \
png \
RColorBrewer \
remotes \
Expand All @@ -43,12 +38,12 @@ RUN install2.r --error --skipinstalled \
ggpmisc \
jose \
R6 \
patchwork \
cowplot \
equatiomatic \
quarto

USER shiny
COPY ./app/ ./myapp
COPY ./bs/R ./myapp
RUN mkdir /home/shiny/results

COPY ./MTT/ /home/MTT
Expand All @@ -58,7 +53,7 @@ RUN bash -c "cd /home/MTT; R CMD INSTALL ."
RUN bash -c "cd /home/comeln; R CMD INSTALL ."

EXPOSE 4001
COPY ./app/ /srv/shiny-server/
COPY ./bs/R /srv/shiny-server/
COPY ./run.sh .

ENV SHINY_LOG_STDERR=1
Expand Down
4,415 changes: 0 additions & 4,415 deletions bs/.development/Formulas.html

This file was deleted.

31 changes: 24 additions & 7 deletions bs/.development/Formulas.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ show <- function(formula, data) {
model_table <- kable(broom::tidy(model), format = "html", table.attr = "style='display: inline-block; vertical-align: top;'")
html_output <- tags$table(
tags$tr(
tags$td(HTML(data_table)),
tags$td(HTML(formula_table)),
tags$td(HTML(model_table))
tags$td(data_table),
tags$td(formula_table),
tags$td(model_table)
)
)
html_output
}
show_model <- function(f, data) {
model_latex <- extract_eq(lm(f, data = data), wrap = TRUE)
print(model_latex)
model <- data.frame(Model = model_latex)
knitr::kable(model)
}
Expand All @@ -54,7 +55,8 @@ m$term <- terms[m$term]
names(m)[names(m) == "estimate"] <- "ßs"
names(m)[names(m) == "std.error"] <- "Standard error of ßs"
names(m)[names(m) == "statistic"] <- "t-statistic = ßs / Standard error of ßs"
knitr::kable(m)
table <- knitr::kable(m, format = "html", table.attr = "style='display: inline-block; vertical-align: top;'")
tags$table(tags$td(table))
```

## Adding multiple predictors with +
Expand Down Expand Up @@ -82,7 +84,9 @@ m$term <- terms[m$term]
names(m)[names(m) == "estimate"] <- "ßs"
names(m)[names(m) == "std.error"] <- "Standard error of ßs"
names(m)[names(m) == "statistic"] <- "t-statistic = ßs / Standard error of ßs"
knitr::kable(m)
table <- knitr::kable(m, format = "html", table.attr = "style='display: inline-block; vertical-align: top;'")
tags$table(tags$td(table))
```
## Model with main effects and interaction using *

Expand All @@ -108,7 +112,8 @@ m$term <- terms[m$term]
names(m)[names(m) == "estimate"] <- "ßs"
names(m)[names(m) == "std.error"] <- "Standard error of ßs"
names(m)[names(m) == "statistic"] <- "t-statistic = ßs / Standard error of ßs"
knitr::kable(m)
table <- knitr::kable(m, format = "html", table.attr = "style='display: inline-block; vertical-align: top;'")
tags$table(tags$td(table))
```
- This includes the main effects of fertilizer and water as well as their interaction.
- An interaction means that the effect of one predictor depends on the level of another predictor.
Expand All @@ -124,6 +129,17 @@ data <- data.frame(
)
f <-formula(yield ~ fertilizer + water + fertilizer : water, data = data)
show_model(f, data)
formula <- f
model <- lm(formula, data = data)
f <- data.frame(Formula = deparse(formula))
formula_table <- kable(data.frame(Formula = f), format = "html", table.attr = "style='display: inline-block; vertical-align: top;'")
html_output <- tags$table(
tags$tr(
tags$td(formula_table),
)
)
html_output
```
- see in the section before the model is the same it is only another way to express it

Expand Down Expand Up @@ -152,7 +168,8 @@ m$term <- terms[m$term]
names(m)[names(m) == "estimate"] <- "ßs"
names(m)[names(m) == "std.error"] <- "Standard error of ßs"
names(m)[names(m) == "statistic"] <- "t-statistic = ßs / Standard error of ßs"
knitr::kable(m)
table <- knitr::kable(m, format = "html", table.attr = "style='display: inline-block; vertical-align: top;'")
tags$table(tags$td(table))
```
- school represents the primary grouping factor
- class is nested within school, modeling different classes within each school
Expand Down
3 changes: 2 additions & 1 deletion bs/R/MainApp.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ server <- function(input, output, session) {
title = "Defining the formula",
includeHTML("www/formula.html"),
easyClose = TRUE,
footer = NULL
footer = NULL,
size = "l"
))
})

Expand Down
3 changes: 3 additions & 0 deletions bs/R/app.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
source("MainApp.R")

# TODO: define getenv as command line argument
Sys.setenv(RUN_MODE = "BROWSER") # SERVER
# Sys.setenv(RUN_MODE = "SERVER")
options(shiny.autoreload = TRUE)
shinyApp(ui, server)
7 changes: 4 additions & 3 deletions bs/R/loadLibraries.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ library(shinyjs)
library(equatiomatic)
# TODO: add missing libraries to the Dockerfile

if (Sys.getenv("RUN_MODE") == "SERVER") {
library(COMELN)
}
library(COMELN)
library(httr)
library(jose)
library(openssl)
Loading

0 comments on commit 143d487

Please sign in to comment.