在R包中管理外部资产 [英] Managing External Assets in R Package

查看:165
本文介绍了在R包中管理外部资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个名为 slidingify 的R包,这使得从R Markdown文件生成可再现的HTML5幻灯片变得很容易。该包使用来自几个现有HTML5幻灯片生成框架的 css js 文件,如 dzslides , deck.js 等。目前,我已将这些外部资产的下载版本组织到 inst / libraries slidingify 文件夹,以便在安装时自动为用户提供。虽然这种方法很简单,但也有一些缺点:


  1. 这些框架在 github 。在当前的设置下,每次更新任何这些框架时,我都必须推送新版本的包。

  2. 如果我对默认设置进行了调整这些框架附带的 css js ,那么我需要仔细合并更新,以便我不会丢失 slidingify 特定的自定义项。


关于如何进行管理。


  1. 不要用 slidingify 。相反,请提供一个函数,它允许用户添加他们想要的框架。

  2. 添加这些框架到 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:

  1. 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.

  2. If I make any tweaks to the default css and js that come with these frameworks, then I need to merge the updates carefully so that I don't lose slidify specific customizations.

I had a couple of thoughts on how to manage this.

  1. Don't package these libraries with slidify. Instead, provide a function that would allow users to add the frameworks they desire.

  2. Add these frameworks to the inst\libraries folder on slidify, but as submodules. Now, I have no idea if adding them as submodules would get them installed if someone were to use devtools::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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆