许多数据库都与新型冠状病毒肺炎有关,但是目前还没有一个虚拟平台对这些数据源中的大部分数据进行集成。因此想要对 COVID-19 相关的数据进行全面的分析是有难度的,也很难将这些通常是医学信息和外部因素,特别是社会政治因素联系起来。考虑到这一点,新型冠状病毒肺炎数据中心 (COVID-19 Data Hub)致力于开发一个统一的数据集,有助于更好地理解新型冠状病毒肺炎数据。
The goal of COVID-19 Data Hub is to provide the research community with a unified data hub by collecting worldwide fine-grained case data, merged with exogenous variables helpful for a better understanding of COVID-19.
在本教程中,我们将使用 COVID19 的 R 包来构建一个简单而完整的 Shiny 应用程序,这个应用程序是通过 COVID19 这个 R 包来连接新型冠状病毒肺炎数据中心的。
country:the country name. Note that the options are automatically populated using the covid19() function. 国家名称。请注意,选项是使用 covid19() 函数
type:the metric to use. One of c("confirmed", "tests", "recovered", "deaths"), but many others are avaibale. See here for the full list. 使用的度量标准,可以是 c("confirmed", "tests", "recovered", "deaths") 中的一种 , 也可以是除此以外的其他值,完整的名单参考这里。
level:granularity level (country – region – city). 粒度级别(国家-地区-城市)。
date:start and end dates. 开始和结束日期。
输出。
covid19plot: plotly output that will render an interactive plot. 显示交互式图形的 plotly 输出。
将所有内容打包到 fluidPage 函数中:
# Define UI for applicationui<-fluidPage(selectInput("country",label="Country",multiple=TRUE,choices=unique(covid19()$administrative_area_level_1),selected="Italy"),selectInput("type",label="type",choices=c("confirmed","tests","recovered","deaths")),selectInput("level",label="Granularity",choices=c("Country"=1,"Region"=2,"City"=3),selected=2),dateRangeInput("date",label="Date",start="2020-01-01"),plotlyOutput("covid19plot"))
# Define server logicserver<-function(input,output){output$covid19plot<-renderPlotly({if(!is.null(input$country)){x<-covid19(country=input$country,level=input$level,start=input$date[1],end=input$date[2])color<-paste0("administrative_area_level_",input$level)plot_ly(x=x[["date"]],y=x[[input$type]],color=x[[color]])}})}