roxy.package | R Documentation |
This function should help to create R packages with full documentation and updates to a local repository. It supports source and binary packaging (Windows and Mac OS X; see Note section on the limitations).
roxy.package(
pck.source.dir,
pck.version,
pck.description,
R.libs,
repo.root,
pck.date = Sys.Date(),
actions = c("roxy", "package"),
cleanup = FALSE,
rm.vignette = FALSE,
R.homes = R.home(),
R.libs.append = NULL,
Rcmd.options = c(install = "--install-tests", build =
"--no-manual --no-build-vignettes --md5", check = "--as-cran", Rd2pdf =
"--pdf --no-preview"),
URL = NULL,
deb.options = NULL,
readme.options = NULL,
html.options = NULL,
ChangeLog = list(changed = c("initial release"), fixed = c("missing ChangeLog")),
Rbuildignore = NULL,
Rinstignore = NULL,
OSX.repo = list(main = "contrib", symlinks = "el-capitan"),
pck.aliases = NULL,
...
)
pck.source.dir |
Character string, path pointing to the root directory of your package sources. |
pck.version |
Character string,
defining the designated version number. Can be omitted if actions don't
include |
pck.description |
Data.frame holding the package description (see Examples section). Any data.frame with valid fields
will do,
but you should use |
R.libs |
Character string, valid path to the R library where the package should be installed to. |
repo.root |
Character string, valid path to a directory where to build/update a local package repository. |
pck.date |
Date class object or character string of the release date in YYYY-MM-DD format. Defaults to |
actions |
Character vector, must contain at least one of the following values:
Note that |
cleanup |
Logical,
if |
rm.vignette |
Logical,
if |
R.homes |
Path to the R installation to use. Can be set manually to build packages for other R versions than the default one,
if you have installed them in parallel. Should probably be used together with |
R.libs.append |
An optional vector of paths pointing to R libraries to always be included for package lookup. These locations will be added
to package build calls by appending them to the |
Rcmd.options |
A named character vector with options to be passed on to the internal calls of |
URL |
Either a single character string defining the URL to the root of the repository (i.e.,
which holds the directories
These URLs are not the path to the local file system,
but should be the URLs to the respecive repository as it is available
via internet. This option is necessary for (and only interpreted by) the actions |
deb.options |
A named list with parameters to pass through to |
readme.options |
A named list with parameters that add optional extra information to an initial README.md file,
namely instructions to install the package
directly from a GitHub repository. Ignore this if you don't use GitHub. Theoretically,
you can overwrite all values of the internal
function
All other missing values are then guessed from the other package information. It is then assumed that the GitHub repo has the same name as the package. |
html.options |
A named list with parameters to be used for generating the HTML files of the repository. These values are recognized:
|
ChangeLog |
A named list of character vectors with log entry items. The element names will be used as section names in the ChangeLog entry,
and each character string in a vector will be pasted as a log item. The news you provide here will be appended to probably present news,
while
trying to prevent duplicate entries to appear. If you need more control,
don't use the |
Rbuildignore |
A character vector to be used as lines of an |
Rinstignore |
A character vector to be used as lines of an |
OSX.repo |
A named list of character vectors,
one named |
pck.aliases |
A character vector,
defining all aliases to be used in the |
... |
Additional options passed through to |
For the documentation roxygen2
[1] is used. Next to the actual in-line documentation of the package's contents,
you only need to
prepare a data.frame to be used to write a package DESCRIPTION
file. See the example section for details on that. This means
that you neither edit the DESCRIPTION
nor the *-package.R
file manually,
they will both be created automatically
by this function with contents according to these settings!
If you want to check out the effects of roxy.package() without touching you actual package sources,
try sandbox
to set up a safe testing environment.
The repository will have this directory structure, that is,
below the defined repo.root
:
./src/contrib
Here go the source packages
./bin/windows/contrib/$RVERSION
Here go the Windows binaries
./bin/macosx/contrib/$RVERSION
Here go the Mac OS X binaries (see OSX.repo
for further options)
./pckg/index.html
A global package index with links to packages' index files,
if actions included "html"
./pckg/web.css
A CRAN-style CSS file, if actions included "html"
./pckg/$PACKAGENAME
Here go documentation PDF and vignette,
as well as a ChangeLog
file, if found.
and an index.html
with package information, if actions included "html"
.
This is probably a bit off-standard, but practical if you several packages.
See cl2news
for details.
The options R.libs
and R.homes
can take a vector of strings. This can be used to build packages for multiple R versions,
provided you installed them on your system. By default,
roxy.package
will only use the first entry of both and ignore the rest,
except if you use the "buildEmAll"
action. This makes it easy to use roxy.package
in a script,
as you can turn multiple builds
on and off with one action, and leave the rest untouched.
If you're running GNU/Linux,
an easy way of preparing for multiple builds is to fetch the R sources from CRAN, calling
"./configure"
with something like "--prefix=$HOME/R/<R version>"
,
so that "make install"
installs to that path.
Let's assume you did that with R 3.4.4 and 3.3.3,
you could then call roxy.package
with options like
R.homes=c("home/user/R/R-3.4.4",
"home/user/R/R-3.3.3")
and R.libs=c("home/user/R/R-3.4.4/lib64/R/library",
"home/user/R/R-3.3.3/lib64/R/library")
. If you add "buildEmAll"
to the actions to perform,
roxy.package
will then
call itself recursively for each given R installation; if you omit "buildEmAll"
,
it will only build packages for R 3.4.4, as that
is the first configured version.
One thing you should be aware of is that roxy.package
will not perform all actions each time. That is because some of them,
namely
"roxy"
, "cite"
, "license"
, "doc"
, "cl2news"
,
"news2rss"
, "cleanRd"
, "readme"
,
"buildVignettes"
, and "vignette"
,
would overwrite previous results anyway,
so they are only considered during the first run. Therefore, you should always place the R version which
should be used for these actions first in line. The "html"
action will list all Windows and OS X binary packages. The "deb"
action will only actually debianize and build a binary package during the first run, too.
On Windows,
the actions "doc"
and "check"
will only work correctly if you have installed and configured LaTeX
accordingly, and you will also need Rtools set up for packaging.
The CRAN policies can sometimes be very strict. This package should allow you to produce packages which are suitable
for release on CRAN. But some steps have to be taken care of by yourself. For instance,
CRAN does currently not allow copies of common licenses
in a source package, nor a debian
folder. Therefore,
if your package is supposed to be released on CRAN, you should include
Rbuildignore=c("debian", "LICENSE")
to the function call.
If you want to rebuild binaries of something that was already released,
i.e. by using the "binonly"
action,
and if your source directory is a git repository,
then the action "gitCheckout"
can temporarily checkout the source version to build
and switch back to the status quo afterwards again. This might or might not work as you expect,
depending on whether you organize your code like
it is expected here. That is, each release must be tagged properly,
with the exact version number as the tag name. You should also commit all
current changes to the code before you use this. Internally,
roxy.package
will try to find out the current branch of the git repository,
then checkout the version number you provided as the new branch or tag,
do all the packaging, and checkout bach to the previous branch.
The binary packaging is done simply by zipping (Windows) or targzipping (Mac OS X) the built and installed package. This should do the trick as long as your package is written in pure R code. It will most likely not produce usable packages if it contains code in other languages like C++.
[1] https://CRAN.R-project.org/package=roxygen2
package_description
for proper package description,
and
sandbox
to run roxy.package() in a sandbox.
## Not run:
## package description as data.frame:
pckg.dscrptn <- package_description(
Package="SquareTheCircle",
Type="Package",
Title="Squaring the circle using Heisenberg compensation",
Author="Ernst Dölle [aut, cre, cph], Ludwig Dölle [trl,
ctb] (initial translation to whitespace)",
AuthorsR="c(person(given=\"Ernst\", family=\"Dölle\",
email=\"e.a.doelle@example.com\",
role=c(\"aut\", \"cre\", \"cph\")),
person(given=\"Ludwig\", family=\"Dölle\",
role=c(\"trl\", \"ctb\"),
comment=\"initial translation to whitespace\")
)",
Maintainer="E.A. Dölle <doelle@eternalwondermaths.example.org>",
Depends="R (>= 2.10.0),heisenberg (>= 0.23),tools",
Enhances="rkward",
Description="This package squares the circle using Heisenberg compensation.
The code came from a meeting with Yrla Nor that i had in a dream. Please
don't forget to chain your computer to the ground, because these
algorithms might make it fly.",
License="GPL (>= 3)",
Encoding="UTF-8",
LazyLoad="yes",
URL="http://eternalwondermaths.example.org"
)
# hint no. 1: you *don't* specify version number and release date here,
# but all other valid fields for DESCRIPTION files must/can be defined
# hint no. 2: most of this rarely changes, so you can add this to the
# internals of your package and refer to it as
# roxy.package(pck.description=SquareTheCircle:::pckg.dscrptn, ...)
# hint no. 3: use "AuthorR" for the "Author@R" field, or "AuthorsR" for
# R >= 2.14, to work around naming problems
roxy.package(pck.source.dir="~/my_R_stuff/SquareTheCircle",
pck.version="0.01-2",
pck.description=pckg.dscrptn,
R.libs="~/R",
repo.root="/var/www/repo",
actions=c("roxy", "package", "doc"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.