Не могу сделать мое блестящее приложение R для отображения графика ggplot - PullRequest
0 голосов
/ 28 февраля 2019

Я пытаюсь отобразить реактивный ggplot в моем блестящем приложении R, но оно не работает, и я не уверен, почему.Если кто-то может точно определить, почему он не работает, он будет очень признателен.

Ниже приведен мой код:

1.ui

ui <- fluidPage(titlePanel("Sample Size Calculator for Binary     Covariates from Dog Data Based on Heish et. al (1998)"),
            helpText("This sample size Calculator is based on the paper 'A Simple Method of Sample Size Calculation for Linear and Logistic Regression' by Heish et al. (1998)",
                     "This calculator treats each covariate as a binary variable, based on the cutoff point of your choice.",
                     "The set of covariates considered in the model are those set of covariates in which their desirable cutoff levels were successfully identified by their ROC curves. ",
                     "Please select Significance Level, and  Cutoff Levels of each covariate that you would like to implement. The plot of Sample Size vs. Power will be displayed below:"),   
  selectInput("diagType", "Diagnosis Outcome of Interest:", c("Cancer", "Sepsis", "SIRS")),
  selectInput("alpha1", "Significance Level:", c("0.05", "0.01", "0.001")),
 conditionalPanel( condition = "input.diagType == 'Cancer'",
                sliderInput("bin1", label = "Cut off level for TK:", min=1, max=20, value=10),
                sliderInput("bin2", label = "Cut off level for AGE:", min=3, max=12, value=6),
                sliderInput("bin3", label = "Cut off level for BW:", min=1, max=40, value=20)),
  conditionalPanel( condition = "input.diagType == 'Sepsis'",
                sliderInput("bin4", label = "Cut off level for CRP:", min=1, max=45, value=22.5),
                sliderInput("bin5", label = "Cut off level for WBC:", min=13, max=25, value=12.5),
                sliderInput("bin6", label = "Cut off level for Temp:", min=103, max=106, value=103)),
  conditionalPanel( condition = "input.diagType == 'SIRS'",
                sliderInput("bin7", label = "Cut off level for CNP:", min=7, max=16, value=8),
                sliderInput("bin8", label = "Cut off level for Pulse:", min=104, max=180, value=135)),

  mainPanel(plotOutput("plot"))
  )

2.SERVER

 server <- function(input, output) {
 d  <- reactive({

   power.vec = c(0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95)

if(input$diagType == "Cancer"){
a = input$alpha1  
b1 = input$bin1
b2 = input$bin2
b3 = input$bin3
e<-calculator.cancer(a,b1,b2,b3)
}

if(input$diagType == "Sepsis"){
  a = input$alpha1  
  b4 = input$bin4
  b5 = input$bin5
  b6 = input$bin6
  e<-calculator.sepsis(a,b4,b5,b6)
} 

  if(input$diagType == "SIRS"){
   a = input$alpha1  
   b7 = input$bin7
   b8 = input$bin8
   e <-calculator.sirs(a,b7,b8)
   }
 })

 output$plot <- renderPlot({
       b <- d()
       p <- ggplot(b, aes(x = power.vec, y = e) + labs(
                                            x = "Level of Power",
                                            y = "Sample Size",
                                            title = "Plot of Sample Size versus Power") + geom_point() + geom_line())
   print(p)

      })
  }
shinyApp(ui, server) 

Почему мой ggplot не отображается?Спасибо,

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...