为什么我得到占位符错误,当我试图打印verbatimTextOutput在闪亮的应用程序?

mcdcgff0  于 2023-07-31  发布在  其他
关注(0)|答案(1)|浏览(89)

在下面的应用程序中,我试图打印paste()结果,但我得到"shiny-text-output noplaceholder"错误。

library(shiny)
library(shinyWidgets)
library(shinydashboard)

centers<-structure(list(State = "Alabama", Y = 32.7760928445334, X = -86.830460056472), row.names = 20L, class = "data.frame")

#dashboard
ui <- dashboardPage(
  
  
  dashboardHeader(title="Mock up"),
  #sidebar  
  dashboardSidebar(
    collapsed = T
  ),
  #body
  dashboardBody(
    paste("LONGITUDE:",verbatimTextOutput("v1"),"LATITUDE:",verbatimTextOutput("v2")),
    
    
  )
)
#server part
server <- function(input, output) {
  output$v1<-renderText({
    #centers<-subset(centers,State%in%input$p3)
    centers[1,2]  
  })
  output$v2<-renderText({
    #centers<-subset(centers,State%in%input$p3)
    centers[1,3]  
  })
  
 
}

shinyApp(ui, server)

字符串

rjee0c15

rjee0c151#

您必须返回renderText内部的字符串。将paste重新排列为renderText,并在dashboardBody中仅使用verbatimTextOutput


的数据

library(shiny)
library(shinyWidgets)
library(shinydashboard)

centers <-
    structure(
        list(
            State = "Alabama",
            Y = 32.7760928445334,
            X = -86.830460056472
        ),
        row.names = 20L,
        class = "data.frame"
    )

#dashboard
ui <- dashboardPage(
    dashboardHeader(title = "Mock up"),
    #sidebar
    dashboardSidebar(collapsed = T),
    #body
    dashboardBody(verbatimTextOutput(outputId = "v"))
)
#server part
server <- function(input, output) {
    output$v <- renderText({
        paste("LONGITUDE:", centers[1, 2], " LATITUDE:", centers[1, 3])
    })
}

shinyApp(ui, server)

字符串

相关问题