我正在嘗試在Shiny中構建一個血壓評估工具,該工具將提供有關人員BP數量的指導。Shiny中的BP評估工具無法找到函數「範圍」
這裏是我的ui.R
庫(閃亮)
shinyUI(fluidPage(
titlePanel("Blood pressure assessment"),
fluidRow(
column(3,
h3("Systolic BP"),
h4("The first/top number"),
sliderInput("x1", label = "mm Hg", min = 90, max = 200,
value = 90, animate = TRUE)),
column(3,
h3("Diastolic BP"),
h4("The second/bottom number"),
sliderInput("x2", label = "mm HG", min = 50, max = 120,
value = 50, animate = TRUE))),
column(3,
h4("Your range"),
verbatimTextOutput("ranges")),
column(3,
br(),
actionButton("submit", "Submit"))))
這裏是我的server.R文件
shinyServer(function(input, output) {
function(ranges) { reactiveValues(normal = "Normal Range",
caution = "Caution Range = Prehypertension",
high = "High Range = Stage 1 Hypertension",
very = "Very High Range = Stage 2 Hypertension")}
dataInput <- reactive({
if(input$x1 > 160){return()} else{
if(input$x2 > 100){return("very")}
}
if(input$x1 == 140:159){return()} else{
if(input$x2 == 90:99){return("high")}
}
if(input$x1 == 120:139){return()} else{
if(input$x2 == 80:89){return("caution")}
}
if(input$x1 < 120){return()} else{
if(input$x2 > 80) {return("normal")}
}
})
observeEvent(input$submit, {
output$ranges <- renderPrint({ranges(input$x1, input$x2)})
})
}
)
說回來,當我嘗試運行應用程序的響應是
Error in func() : could not find function "ranges"
任何想什麼我做錯了。我懷疑自己做得比自己需要更復雜,或者我錯過了一些非常明顯的事情。這是我第一個閃亮的應用程序。
Insi你試圖使用函數'ranges'來渲染'renderPrint'。似乎你沒有正確地定義它。 –