定期自动更新FlexR中的flexdashboard
我使用定期自动更新FlexR中的flexdashboard,r,plotly,flexdashboard,R,Plotly,Flexdashboard,我使用R中的flexdashboard包创建了一个仪表板。我希望在两个问题上得到一些建议 我的仪表板中的一些数据是使用插件从在线来源提取的,需要每天更新。有没有一种方法可以让我自动将仪表板设置为在一天中的某个时间更新,而不必总是手动点击knit 我的仪表板中嵌入了一些plotly图像。有没有办法在plotly菜单中添加一个功能,可以将图像中的数据导出为excel格式(类似于将每个图像导出为png) 这是我的YAML --- title: "Macroeconomic Dashboa
R
中的flexdashboard
包创建了一个仪表板。我希望在两个问题上得到一些建议
plotly
图像。有没有办法在plotly
菜单中添加一个功能,可以将图像中的数据导出为excel格式(类似于将每个图像导出为png)
---
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, 18078, 18109, 18140, 18170, 18201, 18231, 18262, 18293,
18322, 18353, 18383, 18414), class = "Date"), Key = c("Slate Balance",
"Slate Balance", "Slate Balance", "Slate Balance", "Slate Balance",
"Slate Balance", "Slate Balance", "Slate Balance", "Slate Balance",
"Slate Balance", "Slate Balance", "Slate Balance", "Slate Balance",
"Over/Underrecovery", "Over/Underrecovery", "Over/Underrecovery",
"Over/Underrecovery", "Over/Underrecovery", "Over/Underrecovery",
"Over/Underrecovery", "Over/Underrecovery", "Over/Underrecovery",
"Over/Underrecovery", "Over/Underrecovery", "Over/Underrecovery",
"Over/Underrecovery"), Value = c(46.18, 89.89, 18.17, 0, -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, -33.01, 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_加载(整齐、绘图)
p1%过滤器(键=='Slate Balance'|键=='Over/Underrecovery'),位置='dodge',状态='identity')+
刻度填充手册(数值=c('75002B','EFBE93'))+
比例x日期(分段=序号(表头)(slate$日期,1),
尾部(slate$日期,1),
截止日期='2个月',日期标签='%b-%Y')+
连续刻度(断开=顺序(-400400,比=50))+
实验室(百万新西兰元)+
主题(legend.title=element\u blank())+
主题_bw()+
geom_hline(yintercept=0,color=“red”,线型=‘虚线’)
p1%>%ggplotly(工具提示=c('Date','Value'))%>%
布局(图例=列表(方向=“h”,x=0.25,y=1.1))%>%
添加注释(xref='paper',yref='paper',x=1,y=-0.09,text='*Source-矿产和能源部',showarrow=F,
字体=列表(大小=10,颜色=黑色)
蒂亚 我不确定这是否有效,我的一个想法是使用
运行时:shinny
,使数据源成为被动的,并用于更新data@starja我如何才能将reactivePoll
合并到我的YAML中?您不将其包括在YAML中,但必须在降价中重写R函数,在这里了解如何将Shining与flexdashboard结合使用:
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, 1),
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'))