我正在尝试将 Forecast.io 的天气预报嵌入到 Shiny 的仪表板中。我最初在使用 & 符号时遇到了麻烦,但看到一篇文章提供了如何使用特殊字符格式化 HTML 代码的示例。然而,当我运行该应用程序时,我看到一个简单的“未找到”,即使我知道该链接有效并且格式正确。我不确定我错过了什么。
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
)
),
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidRow(
column(12,
mainPanel(htmlOutput("frame")
)
)
)
)
)
)
)
server <- shinyServer(function(input, output) {
output$frame <- renderUI({
tags$iframe(id = 'app', src = url("https://forecast.io/embed/#lat=42.3583&lon=-71.0603&name=Downtown Boston"), width = '100%')
})
})
shinyApp(ui,server)
最佳答案
使用插入的仪表板进行更新
我将 url 从服务器传输到用户界面:
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard",
tabName = "dashboard",
icon = icon("dashboard")
)
)
),
dashboardBody(
tabItems(
tabItem(
tabName = "dashboard",
fluidRow(
tags$iframe(
seamless = "seamless",
src = "https://forecast.io/embed/#lat=42.3583&lon=-71.0603&name=Downtown Boston",
height = 800, width = 1400
)
)
)
)
)
)
server <- function(input, output) {}
shinyApp(ui, server)
关于r - 将天气 iframe 嵌入到 Shiny Dashboard 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46307497/