Loading required package: Hmisc
Attaching package: 'Hmisc'
The following objects are masked from 'package:dplyr':
src, summarize
The following objects are masked from 'package:base':
format.pval, units
Attaching package: 'rms'
The following object is masked from 'package:shiny':
validate
library(rmda)
IPF Probabilty Calculator
IPF_calc <-read_csv("Dataset/IPF_calculator.csv")
New names:
Rows: 622 Columns: 3119
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," chr
(88): SSID, NTP_Exc, Dx2, Dx3, Site.x, Site2, Sex.x, Race.x, Tob, py,... dbl
(3003): ...1, Sample_ID, Dx, IPF, Age_draw, Draw_date, FVC_base, FVCpct... lgl
(27): Exclude_rsn, PFT_prox, E_CigYears, E_Cig_Status, MOTHER, FATHER... date
(1): scan_date
ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
Specify the column types or set `show_col_types = FALSE` to quiet this message.
• `` -> `...1`
IPF_calc$UIP <-as.factor(IPF_calc$UIP)IPF_calc$HP_antigen <-as.factor(IPF_calc$HP_antigen)# Create the modelmodel_3 <-glm(Dx ~ Sex.x + HP_antigen + UIP + MMP12, data = IPF_calc, family = binomial)# Generate IPF probability calculatorui <-fluidPage(titlePanel("IPF probability calculator: "),sidebarLayout(sidebarPanel(selectInput("Sex.x", "Sex:", choices =c("Male", "Female")),selectInput("HP_antigen", "Positive HP-related IgG:", choices =c("Yes", "No")),selectInput("UIP", "Definite or Probable UIP on CT:", choices =c("Yes", "No")),numericInput("MMP12", "MMP12 value:", value =3.5) ),mainPanel(verbatimTextOutput("prediction") ) ))server <-function(input, output) { output$prediction <-renderPrint({# Create a new data frame with proper factor conversions: new_data <-data.frame(Sex.x =factor(tolower(input$Sex.x), levels =c("female", "male")),HP_antigen =factor(ifelse(input$HP_antigen =="Yes", "1", "0"), levels =c("0", "1")),UIP =factor(ifelse(input$UIP =="Yes", "1", "0"), levels =c("0", "1")),MMP12 = input$MMP12 )# Predict probability using model_3 prob <-predict(model_3, newdata = new_data, type ="response") percentage <- prob *100paste("Predicted Probability of IPF rather than FHP:", round(percentage, 2), "%") })}shinyApp(ui = ui, server = server)
Shiny applications not supported in static R Markdown documents