相互影响。分析。交流。
采用一种新鲜的互动方法,用闪亮讲述您的数据故事。让用户与您的数据和分析进行交互。并与R一起做。


Shiny是一个R软件包,可以轻松地直接从R中构建交互式Web应用程序。您可以在网页上托管独立应用程序或将其嵌入其中R MARKDOWN文档或构建仪表板。您还可以扩展您的闪亮应用程序CSS主题,,,,htmlwidgets和JavaScript动作
Shiny将R的计算能力与现代网络的交互性结合在一起。
这是一个闪亮的应用程序
闪亮的应用程序很容易编写。不需要网络开发技能。

Shiny带有各种内置的输入小部件。使用最小语法,可以包括应用程序中左侧显示的小部件:
#选择要绘制selectInput的趋势类型(inputId =“ type”,label = strong(“趋势索引”),choices = unique(trend_data $ type),selected =“ travel =“ travel”)#选择要绘制的日期范围要绘制为deTaterangeInput(“”日期”,强(“日期范围”),start =“ 2007-01-01”,end =“ 2017-07-31”,min =“ 2007-01-01”,max =“ 2017-07-07-31”)
显示输出同样轻松:
mainpanel(plotOutput(outputId =“ lineplot”,height =“ 300px”),textOutput(outputId =“ desc”),tags $ a(href =“ https://www.google.com/finance/finance/finance/finance/domestic_trends”,“ source”,“ source”,“ source”:Google国内趋势“,target =“ _blank”))))
像往常一样在R中构建图或表格,并通过调用适当的渲染功能使它们反应:
输出$ linePlot <-RenderPlot({plot(x = selected_trends()$ date,y = selected_trends()$ close,type =“ l”,xlab =“ date”,ylab =“趋势index”)})
是否想了解我们如何构建左侧显示的Google趋势索引应用程序?有关完整的源代码,请参见下一个选项卡。

#加载软件包库(Shiny)库(ShinyThemes)库(dplyr)库(readr)#加载数据trend_data <-read_csv(“ data/trend_data.csv”)UI UI UI < -  fluidPage(theme = Shinytheme(“ Lumen”),TitlePanel(“ Google趋势索引”),sidebarlayout(sidebarlayout(sidebarpanel(#选择绘制prot selectInput的趋势类型)”),选择= unique(trend_data $ type),selected =“ travel”),#选择要绘制的日期范围是deTaterangeInput(“ date”,strong(“日期范围”),start =“ 2007-01-01”,end =“ 2017-07-31”,min =“ 2007-01-01”,max =“ 2017-07-31”),#选择是否叠加平滑趋势线CheckboxInput(inputId =“ Smimo Orto =“ Smoto”,label = strong = strong(“覆盖平滑趋势线”),值= false),#仅在检查顺滑的conditdyAlpanel(条件=“ input.smoother == true”时,SliderInput(inputId =“ f”,label =“ Smooter Span:”)才显示#显示。,min = 0.01,max = 1,值= 0.67,步骤= 0.01,animate = animationOptions(interval = 100)),html(“较高的值给出更多的平滑度。”))),#output:Description,lineplot和参考mainpanel(plotID =“ lineplot”,高度=“ 300px”),textOutput(outputID = utputID =“ desc”),标签$ a(href =“ https://www.google.com/finance/finance/domestic_trends”,“来源:Google forge tarrents”,target =“ _blank”)))#定义服务器功能服务器<- 函数(输入,输出){#子集数据selection_trends < -  eactive({req(input $ date)validate(需要(!is.na(input $ date $ [1])&!is.na(输入$ date [2 [2]]),“错误:请同时提供一个开始日期和结束日期。”))验证(需要(输入$ DATE [1] <输入$ DATE [2],“错误:开始日期应比结束日期早。”)trend_data%>%过滤器(type ==输入$ type,date> as.posixct(input $ date [1])和date % pull(text) paste(trend_text, "The index is set to 1.0 on January 1, 2004 and is calculated only for US search traffic.") }) } # Create Shiny object shinyApp(ui = ui, server = server)
托管和部署
通过使用自己的服务器或Rstudio的托管服务将闪亮的应用程序放在网络上。英格兰vs伊朗让球

学到更多