r - 如何将 covid19.analytics 中的 live.map 功能添加到闪亮的应用程序中?
问题描述
我正在尝试创建一个 covid19 交互式信息应用程序,但将 covid19.analytics 包中的 live.map() 添加到我的应用程序时遇到了很多麻烦
library(shiny)
library(shinythemes)
library(covid19.analytics)
library(plotly)
ui <- fluidPage(theme=shinytheme("cosmo"),
navbarPage( "COVID 19 APPLICATION",
tabPanel(
"Interactive COVID 19 MAP",
sidebarPanel(
),
mainPanel(
plotlyOutput("map")
)
), tabPanel(
"Countries",
sidebarPanel(
selectInput(inputId = "countries", label = "country selection", choices = c("country 1", "country 2", "country 3")),
),
mainPanel(
plotOutput( outputId = "countries")
)
),
tabPanel(
"coolness XD",
sidebarPanel( ),
mainPanel(
plotOutput( outputId = "coolness")
)
)
),
)
server <- function(input,output){
output$map <- renderPlotly({
x <- live.map()
output$map <- x
})
}
shinyApp(ui=ui,server=server)
output$map <- renderPlotly({
x <- live.map()
output$map <- x
})
}
shinyApp(ui=ui,server=server)
我仍然是闪亮的初学者,所以使用 renderplot/renderplotly 函数有点令人困惑。有谁知道我该如何解决这个问题?
解决方案
您有几件事需要解决:
在 live.map fn 中你需要设置参数,
interactive.display=FALSE
否则live.map
会启动它自己的 web 渲染您的服务器部分需要修改如下,
server <- function(input,output){
output$map <- renderPlotly({
x <- live.map(interactive.display=FALSE)
})
}
IE。您不需要从 renderPlotly 中将 x 重新分配给 output$map
Take a look also at some of the examples from the covid19.analytics dashboard explorer, https://github.com/mponce0/covid19.analytics/blob/master/R/covid19_dashboard.R
- Finally the last "orphan"
output$map <- ...
outside the server fn definition should be removed and only once instance ofshinyApp(ui=ui,server=server)
is needed.
推荐阅读
- command - 更改前缀的命令
- django - 如何在 Django 的浏览器中嵌入 PDF 而不是下载它?
- python - 我可以使用 YouTube Data API v3 按日期获取视频的观看次数吗?
- javascript - 基于三个或更多输入的 Lodash 过滤器
- c# - 如何使用带有初始化程序的代码优先方法创建数据库
- java - iText 中不支持 getInstant
- ar.js - AR.js 选择常规镜头的多相机智能手机
- python - 我正在尝试创建一个 reduce 函数,但是当我需要调用该函数时,我不明白第一个参数应该是什么
- python - “NoneType”对象没有属性“_inbound_nodes”错误
- python - 在 Python 中从字符串中提取信息