2016-08-16 92 views
2

我创建了一个包含使用传单包的地图的flexdashboard。如何在FlexDashboard中包含javascript和css?

我需要能够在地图上的一个区域内,选择标记,这样我可以显示基于这些指标汇总统计。 leaflet-locationfilter似乎提供我所需要的,但我需要弄清楚如何将这包括在生成的HTML文件中。我曾尝试在flexdashboard标题中使用“includes”,但这会产生错误。下面是一个简单的测试案例:

--- 
title: "Dashboard Title" 
output: 
    flexdashboard::flex_dashboard: 
    orientation: columns 
    vertical_layout: fill 
    includes: includes(in_header = "TEST.HTML", before_body = "TEST.HTML", after_body = "TEST.HTML") 
--- 

...这里的test.html是:

<!-- TEST TEST TEST --> 

但这种失败:

输出文件:Dashboard.knit.md

错误包括$ in_header:$操作是 呼叫原子向量无效: - > - >覆盖 - > pandoc_include_args 执行暂停

我不得不求助于阅读the code弄清楚如何做到这一点,因为它似乎并没有被记录任何地方,但我显然错过了一些东西。

有什么建议吗? (。第4页)

回答

1

相反,使用R内置的像documentationincludes功能奇怪的说做的,用YAML来代替:

--- 
title: "Dashboard Title" 
    output: 
    flexdashboard::flex_dashboard: 
     orientation: columns 
     vertical_layout: fill 
     includes: 
      in_header: "TEST.HTML" 
      before_body: "TEST.HTML" 
      after_body: "TEST.HTML" 
--- 

然而,包括单张插件的方式不同除了通过flexdashboard。使用单张自己dependencies说法:

map$dependencies <- c(map$dependencies, list(htmlDependency(
    name = "Leaflet.locationfilter", 
    version = "0.1", 
    src = "PATH_TO_DIRECTORY", 
    script = "locationfilter.js", 
    stylesheet = "locationfilter.css" 
))) 
相关问题