在R包中管理外部资产 [英] Managing External Assets in R Package
问题描述
我正在写一个名为 slidingify
的R包,这使得从R Markdown文件生成可再现的HTML5幻灯片变得很容易。该包使用来自几个现有HTML5幻灯片生成框架的 css
和 js
文件,如 dzslides ,
deck.js
等。目前,我已将这些外部资产的下载版本组织到 inst / libraries
slidingify
文件夹,以便在安装时自动为用户提供。虽然这种方法很简单,但也有一些缺点:
-
这些框架在
github
。在当前的设置下,每次更新任何这些框架时,我都必须推送新版本的包。 -
如果我对默认设置进行了调整这些框架附带的
css
和js
,那么我需要仔细合并更新,以便我不会丢失slidingify
特定的自定义项。
关于如何进行管理。
-
不要用
slidingify
。相反,请提供一个函数
,它允许用户添加他们想要的框架。 添加这些框架到
slidingify
中的 inst \ libraries
文件夹,但是作为子模块
。现在,如果有人使用 devtools :: install_github
,将它们添加为子模块
会让它们安装, 。所以我的问题是,在编写R包时,我如何管理外部非R依赖它们会不断更新?
一个类似的情况是查看软件包 xlsx
和 XLConnect
。
这两个软件包都依赖于Java库。 xlsx
定义(并依赖于)仅包含库的独立程序包 xlsxjars
。
通过这种方式,下游代码与库解耦。
I am writing an R package called slidify
which makes it easy to generate reproducible HTML5 slides from R Markdown files. The package makes use of css
and js
files from several existing HTML5 slide generation frameworks like dzslides
, deck.js
etc. Currently, I have organized the downloaded versions of these external assets in the inst/libraries
folder of slidify
, so that it is automatically available for users upon installation. While this approach is simple, there are some disadvantages:
These frameworks are constantly updated on
github
. Under the current setup, I would have to push a new version of the package everytime any of these frameworks are updated.If I make any tweaks to the default
css
andjs
that come with these frameworks, then I need to merge the updates carefully so that I don't loseslidify
specific customizations.
I had a couple of thoughts on how to manage this.
Don't package these libraries with
slidify
. Instead, provide afunction
that would allow users to add the frameworks they desire.Add these frameworks to the
inst\libraries
folder onslidify
, but assubmodules
. Now, I have no idea if adding them assubmodules
would get them installed if someone were to usedevtools::install_github
.
So my question is, when writing an R package how can I manage external non-R dependencies which are updated constantly?
One analogous situation is to look at the packages xlsx
and XLConnect
.
Both packages depend on Java libraries. xlsx
defines (and depends on) a stand-alone package xlsxjars
that only contains the libraries.
In this way, the downstream code is decoupled from the libraries.
这篇关于在R包中管理外部资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!