在R中的Flexdashboard上定期自动执行更新

问题描述

我已经使用flexdashboard中的R包创建了一个仪表板。我希望在两个问题上得到一些建议

  1. 我的仪表板中的某些数据是使用插件从在线资源中提取的,并且需要每天进行更新。有没有一种方法可以自动将仪表板设置为在一天中的特定时间更新,而不必始终手动进行编织?

  2. 我的仪表板中嵌入了一些plotly图像。有没有一种方法可以在plotly菜单添加一项功能,使用户可以将图像中的数据导出为ex​​cel格式(类似于如何将每个图像导出为png)?

这是我的YAML

---
title: "Macroeconomic Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    logo: bon.png
---

这是我的仪表板中嵌入了plotly图像的代码块和数据的示例

structure(list(Date = structure(c(18048,18078,18109,18140,18170,18201,18231,18262,18293,18322,18353,18383,18414,18048,18414),class = "Date"),Key = c("Slate Balance","Slate Balance","Over/Underrecovery","Over/Underrecovery"),Value = c(46.18,89.89,18.17,-33.01,-16.21,-17.63,-3.94,44.65,205.02,188.88,157.39,2.29,84.06,43.71,-71.72,-18.17,16.8,-1.41,13.68,48.59,160.37,-16.14,-31.49,-155.1)),row.names = c(NA,-26L),class = c("tbl_df","tbl","data.frame"))

pacman::p_load(tidyverse,plotly)

p1 <- ggplot(slate,aes(Date,Value,fill=Key)) +
      geom_bar(data = slate %>% filter(Key=='Slate Balance'|Key=='Over/Underrecovery'),position='dodge',stat='identity') +
      scale_fill_manual(values = c('#75002B','#EFBE93')) +
      scale_x_date(breaks = seq(head(slate$Date,1),tail(slate$Date,by = '2 months'),date_labels = '%b-%Y') +
      scale_y_continuous(breaks = seq(-400,400,by = 50)) +
      labs(y='N$ Million') +
      theme(legend.title = element_blank()) +
      theme_bw() +
      geom_hline(yintercept=0,color = "red",linetype = 'dashed')


p1 %>% ggplotly(tooltip = c('Date','Value')) %>% 
       layout(legend = list(orientation = "h",x = 0.25,y = 1.1)) %>% 
       add_annotations(xref='paper',yref='paper',x=1,y=-0.09,text='*Source - Ministry of mines and Energy',showarrow=F,font=list(size=10,color='black'))

TIA!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)