我正在通过一个R闪亮教程,并决定偏离道路,但我现在迷路了。之前的一次练习让我创建了一个范围滑块,我检查了文档,使之与参数结合在一起。现在我要做的是在它下面创建一个textOutput,以显示min和max之间差值的值。
library(shiny)
ui <- fluidPage(
sliderInput("rang", "Range", value = c(100, 2000), min = 0, max = 15000,
sep = ",", pre = "$", ticks = FALSE, dragRange = TRUE,
width = "600px"),
textOutput(costDiff())
)
server <- function(input, output, session) {
costDiff <- reactive({
costDiff <- input$rang[2] - input$rang[1]
})
output$costDiff <- renderText("$",{
costDiff()
})
}
shinyApp(ui, server)我收到:
Error in costDiff() : could not find function "costDiff"
提前感谢您的帮助!
发布于 2022-01-30 01:12:28
试试这个:
library(shiny)
ui <- fluidPage(
sliderInput("rang", "Range", value = c(100, 2000), min = 0, max = 15000,
sep = ",", pre = "$", ticks = FALSE, dragRange = TRUE,
width = "600px"),
textOutput('costDiff')
)
server <- function(input, output, session) {
costDiff <- reactive({
input$rang[2] - input$rang[1]
})
output$costDiff <- renderText({
paste('$', costDiff())
})
}
shinyApp(ui, server)https://stackoverflow.com/questions/70911063
复制相似问题