我正在尝试在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'。似乎你没有正确地定义它。 –