Last active
August 5, 2021 16:22
-
-
Save datalorax/c32e6eb165bf54d351d9f0d893f7efb0 to your computer and use it in GitHub Desktop.
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
library(shiny) | |
library(shinyWidgets) | |
library(ggplot2) | |
library(equatiomatic) | |
library(gtsummary) | |
library(gt) | |
ui <- fluidPage( | |
titlePanel("equatiomatic w/Shiny"), | |
sidebarLayout( | |
sidebarPanel( | |
multiInput( | |
inputId = "xvars", label = "Select predictor variables :", | |
choices = names(mpg)[-8], | |
selected = "displ" | |
) | |
), | |
mainPanel( | |
uiOutput("eq"), | |
gt_output("tbl") | |
) | |
) | |
) | |
server <- function(input, output) { | |
model <- reactive({ | |
form <- paste("hwy ~ ", paste(input$xvars, collapse = " + ")) | |
lm(as.formula(form), mpg) | |
}) | |
output$eq <- renderUI( | |
withMathJax( | |
helpText( | |
equatiomatic:::format.equation( | |
extract_eq(model(), wrap = TRUE, terms_per_line = 3) | |
) | |
) | |
) | |
) | |
output$tbl <- render_gt({ | |
as_gt(tbl_regression(model())) | |
}) | |
} | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment