在我们写R包的时候,经常需要给包写教程,那么如何才能写出好看/实用/一流的教程呢?它既不能太过简单,又不能太过复杂,而且要容易获得。于是,写R包的人写了个R包来做这件事:
pkgdown的目的是使它快速和容易建立一个网站。您可以在https://pkgdown.r-lib.org上看到pkgdown的作用:这是pkgdown应用到pkgdown的最新版本的输出。通过vignette("pkgdown")或?build_site了解更多信息。
大致的模板是这样的:
当然,你可以自己设计:
http://mc-stan.org/bayesplot/index.html
是不是很好看?心动了吗?关键是你得先有一个想法啊。
In the wild
At last count, pkgdown is used by over 5,000 packages.
Here are a few examples created by contributors to pkgdown:
-
bayesplot (source): plotting functions for posterior analysis, model checking, and MCMC diagnostics.
-
valr (source): read and manipulate genome intervals and signals.
-
mkin (source): calculation routines based on the FOCUS Kinetics Report
-
NMF (source): a framework to perform non-negative matrix factorization (NMF).
Comparing the source and output of these sites is a great way to learn new pkgdown techniques.
网友评论