This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
PackageDevelopment.ctv
335 lines (335 loc) · 40.4 KB
/
PackageDevelopment.ctv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<CRANTaskView>
<name>PackageDevelopment</name>
<topic>Package Development</topic>
<maintainer email="thosjleeper@gmail.com">Thomas J. Leeper</maintainer>
<version>2018-07-31</version>
<info>
<p>Packages provide a mechanism for loading optional code, data, and documentation as needed. At the very minimum only a text editor and an R installation are needed for package creation. Nonetheless many useful tools and R packages themselves have been provided to ease or improve package development. This Task View focuses on these tools/R packages, grouped by topics.</p>
<p>The main reference for packages development is the <a href="http://cran.r-project.org/doc/manuals/R-exts.html">"Writing R Extension"</a> manual. For further documentation and tutorials, see the "Related links" section below.</p>
<p>If you think that some packages or tools are missing from the list, feel free to <a href="mailto:thosjleeper@gmail.com">e-mail</a> me or contribute directly to the Task View by submitting a pull request on <a href="https://github.com/ropensci/PackageDevelopment/blob/master/CONTRIBUTING.md">GitHub</a>.</p>
<p>Many thanks to Christopher Gandrud, Cristophe Dutang, Darren Norris, Dirk Eddelbuettel, Gabor Grothendieck, Gregory Jefferis, John Maindonald, Luca Braglia, Spencer Graves, Tobias Verbeke, and the R-core team for contributions.</p>
<h2 id="first-steps">First steps</h2>
<h3 id="searching-for-existing-packages">Searching for Existing Packages</h3>
<p>Before starting a new package it's worth searching for already available packages, both from a developer's standpoint ("do not reinvent the wheel") and from a user's one (many packages implementing same/similar procedures can be confusing). If a package addressing the same functionality already exists, you may consider contributing at it instead of starting a new one.</p>
<ul>
<li><code>utils::RSiteSearch()</code> allows to search for keywords/phrases in help pages (all the CRAN packages except those for Windows only and some from Bioconductor), vignettes or task views, using the search engine at <a href="http://search.r-project.org/" class="uri">http://search.r-project.org/</a>. A convenient wrapper around <code>RSiteSearch</code> that adds hits ranking is <code>findFn()</code> function, from <pkg>sos</pkg>.</li>
<li><a href="http://rseek.org/">RSeek</a> allows to search for keywords/phrases in books, task views, support lists, function/packages, blogs etc.</li>
<li><a href="https://www.rdocumentation.org/">Rdocumentation</a> allows to search for keywords/phrases in help pages for all CRAN and some Bioconductor/GitHub packages. <pkg>RDocumentation</pkg> (<a href="https://github.com/datacamp/RDocumentation/">GitHub</a>) provides an R client for the site.</li>
<li><a href="http://www.r-pkg.org/" class="uri">http://www.r-pkg.org/</a> is an unofficial CRAN mirror that provides a relatively complete archive of package and read-only access to package sources on Github.</li>
<li><a href="http://dirk.eddelbuettel.com/cranberries/">CRANberries</a> provides a feed of new, updated, and removed packages for CRAN.</li>
<li>If you're looking to create a package, but want ideas for what sorts of packages are in demand, the <a href="https://ropensci.org/">rOpenSci</a> maintains <a href="https://github.com/ropensci/wishlist">a wishlist for science-related packages</a> and <a href="https://github.com/ropensci/webservices/wiki/ToDo">a TODO list of web services and data APIs in need of packaging</a>.</li>
</ul>
<h3 id="initializing-an-r-package">Initializing an R package</h3>
<ul>
<li><code>utils::package.skeleton()</code> automates some of the setup for a new source package. It creates directories, saves functions, data, and R code files provided to appropriate places, and creates skeleton help files and a <code>Read-and-delete-me</code> file describing further steps in packaging</li>
<li><code>create()</code> from <pkg>devtools</pkg> is similar to <code>package.skeleton</code> except it allows to specify <code>DESCRIPTION</code> entries and doesn't create source code and data files from global environment objects or sourced files.</li>
<li>Non-devtools alternatives also exist. <code>kitten()</code> from <pkg>pkgKitten</pkg> allows one to specify the main <code>DESCRIPTION</code> entries and doesn't create source code and data files from global environment objects or sourced files. It's used to initialize a simple package that passes <code>R CMD check</code> cleanly. <pkg>skeletor</pkg> provides another non-devtools skeleton-building function with a wider set of defaults and options.</li>
<li><a href="https://github.com/metacran/mason">mason</a> (not the package on CRAN of the same name) provides a fun, interactive tool for creating a package based on a variety of inputs.</li>
<li><pkg>available</pkg> (<a href="https://github.com/ropenscilabs/available">GitHub</a>) checks whether a package name is available and checks for unintended (typically bad) meanings in a potential package name.</li>
<li><code>Rcpp.package.skeleton()</code> from <pkg>Rcpp</pkg> adds to <code>package.skeleton</code> the C++ via <code>Rcpp</code> handling, by modifying eg. <code>DESCRIPTION</code> and <code>NAMESPACE</code> accordingly, creating examples if needed and allowing the user to specify (with a character vector of paths) which C++ files to include in <code>src</code> directory . Finally the user can decide main <code>DESCRIPTION</code> entries.</li>
<li><pkg>mvbutils</pkg> provides a variety of useful functions for development which include tools for managing and analyzing the development environment, auto-generating certain function types, and visualizing a function dependency graph. <a href="https://github.com/andrie/pagerank">pagerank</a> (not on CRAN) can calculate a package's PageRank from its dependency graph.</li>
<li><a href="https://github.com/hrbrmstr/swagger">swagger</a> (not on CRAN) uses the <a href="http://swagger.io/">Swagger</a> JSON web service API specification to automatically generate an R client package for a web service API.</li>
</ul>
<p>R packages require a <code>Version</code> string in the <code>DESCRIPTION</code> file. Traditionally, packages have been versioned using a <code>MAJOR.MINOR-PATCH</code> format, sometimes using the version's date as the <code>PATCH</code> component. More recently, <a href="http://semver.org/">semantic versioning</a> has become common. <pkg>semver</pkg> (<a href="https://github.com/johndharrison/semver">GitHub</a>) provides tools to parse and manipulate semantic version strings.</p>
<p>When initializing a package, it is worth considering how it should be licensed. CRAN provides <a href="https://cran.r-project.org/web/licenses/">a list of the most commonly used software licences</a> for R packages. <pkg>osi</pkg> (<a href="https://github.com/Ironholds/osi/">GitHub</a>) provides a more comprehensive list in a standardized format.</p>
<h3 id="programming-paradigms">Programming Paradigms</h3>
<p>R is foremost a functional programming language with dynamic typing, but has three built-in forms of object-oriented programming as well as additional object-oriented paradigms available in add-on packages.</p>
<ul>
<li>The built-in S3 classes involve wherein a generic function (e.g., <code>summary</code>) employs a distinct method for an object of a given class (i.e., it is possible to implement class-specific methods for a given generic function). If a package implements new object classes, it is common to implement methods for commonly used generics such as <code>print</code>, <code>summary</code>, etc. These methods must be registered in the package's NAMESPACE file. <pkg>R.methodsS3</pkg> aims to simplify the creation of S3 generic functions and S3 methods.</li>
<li>S4 is a more formalized form of object orientation that is available through <code>methods</code>. S4 classes have formal definitions and can dispatch methods based on multiple arguments (not just the first argument, as in S3). S4 is notable for its use of the <code>@</code> symbol to extract slots from S4 objects. John Chambers's <a href="http://developer.r-project.org/howMethodsWork.pdf">"How S4 Methods Work"</a> tutorial may serve as a useful introduction.</li>
<li>Reference classes were introduced in R2.12.0 and are also part of <code>methods</code>. They offer a distinct paradigm from S3 and S4 due to the fact that reference class objects are mutable and that methods belong to objects, not generic functions.</li>
<li><pkg>aoos</pkg> and <pkg>R.oo</pkg> are other packages facilitating object-oriented programming. <pkg>R6</pkg> (<a href="https://github.com/wch/R6">Github</a>) provides an alternative to reference classes without a dependency on <code>methods</code>.</li>
<li><pkg>proto</pkg> provides a prototype-based object orientated programming paradigm.</li>
<li><pkg>rtype</pkg> provides a strong type system.</li>
<li><a href="https://github.com/gaborcsardi/argufy">argufy</a> (Not on CRAN), provides a syntax for creating functions with strictly typed arguments, among other possible checks.</li>
<li><pkg>lambda.r</pkg>, <a href="https://github.com/hoxo-m/lambdaR">lambdaR</a> (not on CRAN), and <pkg>purrr</pkg> provide interfaces for creating lambda (anonymous) functions.</li>
<li><pkg>functools</pkg> (<a href="https://github.com/paulhendricks/functools">GitHub</a>) provides higher-order functions (Map, Reduce, etc.) common in funcitonal programming.</li>
<li><pkg>later</pkg> (<a href="https://github.com/r-lib/later">GitHub</a>) provides the ability to postpone execution of R or C code.</li>
</ul>
<p>Another feature of R is the ability to rely on both standard and non-standard evaluation of function arguments. Non-standard evaluation is seen in commonly used functions like <code>library</code> and <code>subset</code> and can also be used in packages.</p>
<ul>
<li><code>substitute()</code> provides the most straightforward interface to non-standard evaluation of function arguments.</li>
<li><pkg>rlang</pkg> (<a href="https://github.com/tidyverse/rlang">Github</a>) aims to help developers tools for non-standard evaluation.</li>
<li>An increasingly popular form of non-standard evaluation involves chained expressions or "pipelines". <pkg>magrittr</pkg> provides the <code>%>%</code> chaining operator that passes the results of one expression evaluation to the next expression in the chain, as well as other similar piping operators. <pkg>pipeR</pkg> offers a larger set of pipe operators. <pkg>assertr</pkg> and <pkg>ensurer</pkg> provide (fairly similar) testing frameworks for pipelines.</li>
</ul>
<h3 id="dependency-management">Dependency Management</h3>
<p>Packages that have dependencies on other packages need to be vigilant of changes to the functionality, behaviour, or API of those packages.</p>
<ul>
<li><pkg>CodeDepends</pkg> provides tools for examining dependencies between blocks of code.</li>
<li><pkg>backports</pkg> (<a href="https://github.com/mllg/backports">GitHub</a>) provides reimplementations of functions added to base R packages since v3.0.0, making them available in older versions of R. This gives package developers the ability to reduce or eliminate a dependency on specific versions of R itself.</li>
<li><a href="https://github.com/mkearney/pkgverse">pkgverse</a> (not on CRAN) provides tools for creating an integrated, installable "universe" of R packages, in the style of the <a href="https://www.tidyverse.org/">"tidyverse"</a>.</li>
<li><pkg>packrat</pkg> (<a href="https://github.com/rstudio/packrat">GitHub</a>) provides facilities for creating local package repositories to manage and check dependencies.</li>
<li><pkg>checkpoint</pkg> relies on the Revolution Analytics MRAN repository to access packages from specified dates.</li>
<li><pkg>pacman</pkg> (<a href="https://github.com/trinker/pacman">GitHub</a>) can install, uninstall, load, and unload various versions of packages from CRAN and Github.</li>
<li><pkg>GRANBase</pkg> (<a href="https://github.com/gmbecker/gRAN">GitHub</a>) provides some sophisticated tools for managing dependencies and testing packages conditional on changes.</li>
<li><pkg>cranly</pkg> (<a href="https://github.com/ikosmidis/cranly">GitHub</a>) provides tools for creating and visualizing dependency graphs among packages on CRAN.</li>
<li>Two packages currently provide alternative ways to import objects from packages in non-standard ways (e.g., to assign those objects different names from the names used in their host packages). <pkg>import</pkg> (<a href="https://github.com/smbache/import">GitHub</a>) can import numerous objects from a namespace and assign arbitrary names. <a href="https://github.com/klmr/modules">modules</a> (not on CRAN) provides functionality for importing alternative non-package code from Python-like "modules".</li>
<li><a href="https://github.com/rocker-org">Rocker</a> is an initiative to create Docker configurations for R and packages. <a href="https://github.com/o2r-project/containerit/">containerit</a> (not on CRAN) can be used to package an R workspace and all dependencies as a Docker container.</li>
</ul>
<h2 id="source-code">Source Code</h2>
<h3 id="foreign-languages-interfaces">Foreign Languages Interfaces</h3>
<ul>
<li>R's base functions <code>system()</code>, <code>system2()</code>, and - on Windows - <code>shell.exec()</code> - provide interfaces for calling system functions. <pkg>sys</pkg> (<a href="https://github.com/jeroen/sys/">GitHub</a>) and <a href="https://github.com/r-pkgs/processx">processx</a> (not on CRAN) provide unified, platform-independent APIs for running system processes.</li>
<li><pkg>inline</pkg> eases adding code in C, C++, or Fortran to R. It takes care of the compilation, linking and loading of embedded code segments that are stored as R strings.</li>
<li><pkg>Rcpp</pkg> offers a number of C++ classes that makes transferring R objects to C++ functions (and back) easier. <pkg>RInside</pkg> provides C++ classes for embedding within C++ applications.</li>
<li><pkg>rGroovy</pkg> integrates with the <a href="http://www.groovy-lang.org/">Groovy scripting language</a>.</li>
<li><pkg>rJava</pkg> provides a low-level interface to Java similar to the <code>.Call</code> interface for C and C++. <pkg>helloJavaWorld</pkg> provides an example rJava-based package. <a href="https://dahl.byu.edu/software/jvmr/">jvmr</a> (archived on CRAN) provides a bi-directional interface to Java, Scala, and related languages, while <pkg>rscala</pkg> is designed specifically for Scala.</li>
<li><a href="https://github.com/rustr/rustr">rustr</a> provides bindings to Rust.</li>
<li><a href="https://github.com/schmidtchristoph/reach">reach</a> (not on CRAN) and <pkg>matlabr</pkg> provide rough interfaces to Matlab.</li>
<li><pkg>rPython</pkg>, <pkg>rJython</pkg>, <pkg>PythonInR</pkg>, <a href="http://rpy.sourceforge.net/">rpy2</a> (not on CRAN), and <a href="https://github.com/asieira/SnakeCharmR">SnakeCharmR</a> (not on CRAN) provide interfaces to python. <pkg>reticulate</pkg> (<a href="https://github.com/rstudio/reticulate">GitHub</a>) is a relatively recent interface built by RStudio.</li>
<li><a href="https://github.com/armgong/RJulia">RJulia</a> (not on CRAN) provides an interface with Julia, as does <pkg>XRJulia</pkg>. <a href="https://github.com/JuliaInterop/RCall.jl">RCall</a> embeds R within Julia.</li>
<li><pkg>RStata</pkg> is an interface with Stata. <a href="https://github.com/haghish/Rcall">RCall</a> embeds R in Stata.</li>
<li><code>tcltk</code>, which is a package built in to R, provides an general interface to Tcl, usefully especially for accessing Tcl/tk (for graphical interfaces). <a href="https://github.com/gaborcsardi/after">after</a> (not on CRAN) uses tcltk to run R code in a separate event loop.</li>
<li><pkg>V8</pkg> offers an embedded Javascript engine, useful for building packages around Javascript libraries. <pkg>js</pkg> provides additional tools for working with Javascript code.</li>
</ul>
<p>The <pkg>knitr</pkg> package, which supplies <a href="https://yihui.name/knitr/demo/engines/">various foreign language engines</a>, can also be used to generate documents that call python, awk, ruby, haskell, bash, perl, dot, tikz, sas, coffeescript, and polyglot.</p>
<p>Writing packages that involve compiled code requires a developer toolchain. If developing on Windows, this requires <a href="http://cran.r-project.org/bin/windows/Rtools/">Rtools</a>, which is updated with each R minor release.</p>
<h3 id="debugging">Debugging</h3>
<ul>
<li><pkg>futile.logger</pkg>, <pkg>log4r</pkg>, and <pkg>logging</pkg> provide logging functionality in the style of <a href="https://en.wikipedia.org/wiki/Log4j">log4j</a>.</li>
<li><a href="https://github.com/smbache/loggr">loggr</a> (not on CRAN) aims to provide a simplified logging interface without the need for <code>withCallingHandlers()</code> expressions.</li>
<li><pkg>rollbar</pkg> reports messages and errors to <a href="https://rollbar.com/">Rollbar</a>, a web service.</li>
<li>The <a href="https://github.com/kalibera/rchk">rchk</a> tool provides tools for identifying memory-protection bugs in C code, including base R and packages.</li>
</ul>
<h3 id="code-analysis-and-formatting">Code Analysis and Formatting</h3>
<ul>
<li><pkg>codetools</pkg> provides a number of low-level functions for identifying possible problems with source code.</li>
<li><pkg>lintr</pkg> provides tools for checking source code compliance with a style guide.</li>
<li><pkg>formatR</pkg> and <a href="https://github.com/google/rfmt/">rfmt</a> (not on CRAN) can be used to neatly format source code.</li>
<li><pkg>FuncMap</pkg> provides a graphical representation of function calls used in a package.</li>
<li><pkg>pkggraph</pkg> (<a href="https://github.com/talegari/pkggraph">GitHub</a>) and <a href="https://github.com/MangoTheCat/functionMap">functionMap</a> provide tools useful for understanding function dependencies within and across packages. <a href="https://github.com/ropenscilabs/atomize">atomize</a> can quickly extract functions from within a package into their own package. <a href="https://github.com/hadley/requirements">requirements</a> (not on CRAN) checks R code files for implicit and explicit package dependencies.</li>
<li><pkg>pkgnet</pkg> (<a href="https://github.com/UptakeOpenSource/pkgnet">GitHub</a>) uses concepts from graph theory to quantify the complexity and vulnerability to failure of a software package based upon dependencies between functions and between package dependencies.</li>
</ul>
<h3 id="profiling">Profiling</h3>
<ul>
<li>Profiling data is provided by <code>utils::Rprof()</code> and can be summarized by <code>utils::summaryRprof()</code>. <pkg>prof.tree</pkg> (<a href="https://github.com/artemklevtsov/prof.tree">GitHub</a>) provides an alternative output data structure to <code>Rprof()</code>. <pkg>profmem</pkg> (<a href="https://github.com/HenrikBengtsson/profmem">GitHub</a>) adds a simple interface on top of this.</li>
<li><pkg>profr</pkg> can visualize output from the <code>Rprof</code> interface for profiling.</li>
<li><pkg>proftools</pkg> and <pkg>aprof</pkg> can also be used to analyse profiling output.</li>
<li><a href="https://github.com/rstudio/profvis">profvis</a> (not on CRAN) provides an interactive, graphical interface for examining profile results.</li>
<li><a href="https://github.com/hadley/lineprof">lineprof</a> (not on CRAN) provides a visualization tool for examining profiling results.</li>
<li><a href="https://github.com/analyticalmonk/Rperform">Rperform</a> (not on CRAN) compares package performance across different git versions and branches.</li>
</ul>
<h3 id="benchmarking">Benchmarking</h3>
<ul>
<li><code>base::system.time()</code> is a basic timing utility that calculates times based on one iteration of an expression.</li>
<li><pkg>microbenchmark</pkg> and <pkg>rbenchmark</pkg> provide timings based on multiple iterations of an expression and potentially provide more reliable timings than <code>system.time()</code></li>
</ul>
<h3 id="unit-testing">Unit Testing</h3>
<ul>
<li>Packages should pass all basic code and documentation checks provided by the <code>R CMD check</code> quality assurance tools built in to R. <pkg>rcmdcheck</pkg> provides programmatic access to <code>R CMD check</code> from within R and <a href="https://github.com/r-pkgs/callr">callr</a> (not on CRAN) provides a generic interface for calling R from within R.</li>
<li>R documentation files can contain demonstrative examples of package functionality. Complete testing of correct package performance is better reserved for the <code>test</code> directory. Several packages provide testing functionality, including <pkg>RUnit</pkg>, <pkg>svUnit</pkg>, <pkg>testit</pkg> (<a href="https://github.com/yihui/testit">GitHub</a>), <pkg>testthat</pkg>, <a href="https://github.com/robertzk/testthatsomemore">testthatsomemore</a> (not on CRAN), and <pkg>pkgmaker</pkg>. <pkg>runittotestthat</pkg> provides utilities for converting exiting RUnit tests to testthat tests.</li>
<li><pkg>unitizer</pkg> (<a href="https://github.com/brodieG/unitizer">GitHub</a>) provides tools for regression testing by comparing test output against previous runs of the same tests. The package has extensive vignette-based documentation.</li>
<li><pkg>vdiffr</pkg> (<a href="https://github.com/lionel-/vdiffr">GitHub</a>) can be used for graphical unit tests.</li>
<li><pkg>assertive</pkg>, <pkg>assertr</pkg>, <pkg>checkmate</pkg> <pkg>ensurer</pkg>, and <pkg>assertthat</pkg> provide test-like functions for use at run-time or in examples that will trigger messages, warnings, or errors if an R object differs from what is expected by the user or developer.</li>
<li><pkg>mockr</pkg> (<a href="https://github.com/krlmlr/mockr">GitHub</a>) provides tools to mock a function in a test context. This can be useful for standardizing the test of a function that calls other functions by fixing the output of those function dependencies.</li>
<li><pkg>covr</pkg> and <a href="https://github.com/MangoTheCat/testCoverage">testCoverage</a> (not on CRAN) offer utilities for monitoring how well tests cover a package's source code. These can be complemented by services such as <a href="https://codecov.io/">Codecov</a> or <a href="https://coveralls.io/">Coveralls</a> that provide web interfaces for assessing code coverage.</li>
<li><pkg>withr</pkg> (<a href="https://github.com/jimhester/withr">GitHub</a>) provides functions to evaluate code within a temporarily modified global state, which may be useful for unit testing, debugging, or package development.</li>
<li>The <code>devtools::use_revdep()</code> and <code>revdep_check()</code> functions from <pkg>devtools</pkg> can be used to test reverse package dependencies to ensure code changes have not affected downstream package functionality. <a href="https://github.com/yihui/crandalf">crandalf</a> (not on CRAN) provides an alternative mechanism for testing reverse dependencies.</li>
</ul>
<h3 id="internationalization-and-localization">Internationalization and Localization</h3>
<ul>
<li>There is no standard mechanism for translation of package documentation into languages other than English. To create non-English documentation requires manual creation of supplemental .Rd files or package vignettes. Packages supplying non-English documentation should include a <code>Language</code> field in the DESCRIPTION file.</li>
<li>R provides useful features for the localization of diagnostic messages, warnings, and errors from functions at both the C and R levels based on GNU <code>gettext</code>. <a href="http://developer.r-project.org/Translations30.html">"Translating R Messages"</a> describes the process of creating and installing message translations.</li>
</ul>
<h3 id="creating-graphical-interfaces">Creating Graphical Interfaces</h3>
<ul>
<li>For simple interactive interfaces, <code>readline()</code> can be used to create a simple prompt. <pkg>getPass</pkg> provides cross-platform mechanisms for securely requesting user input without displaying the intput (e.g., for passwords). <code>utils::menu()</code>, <code>utils::select.list()</code> can provide graphical and console-based selection of items from a list, and <code>utils::txtProgressBar()</code> provides a simple text progress bar.</li>
<li><code>tcltk</code> is an R base package that provides a large set of tools for creating interfaces uses Tcl/tk (most functions are thin wrappers around corresponding Tcl and tk functions), though the documentation is sparse. <pkg>tcltk2</pkg> provides additional widgets and functionality. <pkg>qtbase</pkg> provides bindings for Qt. <ohat>RGtk</ohat> (not on CRAN) provides bindings for Gtk and gnome. <pkg>gWidgets2</pkg> offers a language-independent API for building graphical user interfaces in Gtk, Qt, or Tcl/tk.</li>
<li><pkg>fgui</pkg> can create a Tcl/tk interface for any arbitrary function.</li>
<li><pkg>shiny</pkg> provides a browser-based infrastructure for creating dashboards and interfaces for R functionality. <pkg>htmlwidgets</pkg> is a shiny enhancement that provides a framework for creating HTML widgets.</li>
<li><pkg>progress</pkg> (<a href="https://github.com/gaborcsardi/progress">Github</a>) offers progress bars for the terminal, including a C++ API.</li>
</ul>
<h3 id="command-line-argument-parsing">Command Line Argument Parsing</h3>
<ul>
<li>Several packages provide functionality for parsing command line arguments: <pkg>argparse</pkg>, <pkg>argparser</pkg>, <pkg>commandr</pkg>, <pkg>docopt</pkg>, <pkg>GetoptLong</pkg>, and <pkg>optigrab</pkg>.</li>
</ul>
<h3 id="using-options-in-packages">Using Options in Packages</h3>
<ul>
<li><pkg>pkgconfig</pkg> (<a href="https://github.com/gaborcsardi/pkgconfig">GitHu</a>) allows developers to set package-specific options, which will not affect options set or used by other packages.</li>
</ul>
<h2 id="documentation">Documentation</h2>
<h3 id="writing-package-documentation">Writing Package Documentation</h3>
<p>Package documentation is written in a TeX-like format as .Rd files that are stored in the <code>man</code> subdirectory of a package. These files are compiled to plain text, HTML, or PDF by R as needed.</p>
<ul>
<li>One can write .Rd files directly. A popular alternative is to rely on <pkg>roxygen2</pkg>, which uses special markup in R source files to generate documentation files before a package is built. This functionality is provided by <code>roxygen2::roxygenise()</code> and underlies <code>devtools::document()</code>. roxygen2 eliminates the need to learn <em>some</em> of the formatting requirements of an .Rd file at the cost of adding a step to the development process (the need to roxygenise before calling <code>R CMD build</code>). Recent versions of roxygen2 support full markdown-based documentation without the need for any native Rd formatting.</li>
<li><pkg>Rd2roxygen</pkg> can convert existing .Rd files to roxygen source documentation, facilitating the conversion of existing documentation to an roxygen workflow. <a href="https://github.com/r-pkgs/roxygen2md">roxygen2md</a> (not on CRAN) provides tools for further converting Rd markup within roxygen comments to markdown format (supported by the latest versions of roxygen2).</li>
<li><a href="https://github.com/unDocUMeantIt/roxyPackage">roxyPackage</a> (not on CRAN) provides some additional functionality for maintaining package documentation.</li>
<li><pkg>inlinedocs</pkg> and <pkg>documair</pkg> provide further alternative documentation schemes based on source code commenting.</li>
<li><code>tools::parse_Rd()</code> can be used to manipulate the contents of an .Rd file. <code>tools::checkRd()</code> is useful for validating an .Rd file. Duncan Murdoch's <a href="https://developer.r-project.org/parseRd.pdf">"Parsing Rd files"</a> tutorial is a useful reference for advanced use of R documentation. <pkg>Rdpack</pkg> provides additional tools for manipulating documentation files.</li>
<li><pkg>packagedocs</pkg> and <pkg>pkgdown</pkg> can be used to generate static websites from R documentation files.</li>
</ul>
<h3 id="writing-vignettes">Writing Vignettes</h3>
<p>Package vignettes provides additional documentation of package functionality that is not tied to a specific function (as in an .Rd file). Historically, vignettes were used to explain the statistical or computational approach taken by a package in an article-like format that would be rendered as a PDF document using <code>Sweave</code>. Since R 3.0.0, non-Sweave vignette engines have also been supported, including <pkg>knitr</pkg>, which can produce Sweave-like PDF vignettes but can also support HTML vignettes that are written in R-flavored markdown. To use a non-Sweave vignette engine, the vignette needs to start with a code block indicating the package and function to be used:</p>
<blockquote>
<p>% %</p>
</blockquote>
<h3 id="spell-checking">Spell Checking</h3>
<ul>
<li><code>utils</code> provides multiple functions for spell-checking portions of packages, including .Rd files (<code>utils::aspell_package_Rd_files</code>) and vignettes (<code>utils::aspell_package_vignettes</code>) via the general purpose <code>aspell</code> function, which requires a system spell checking library, such as http://aspell.net/, http://hunspell.github.io/, or https://www.cs.hmc.edu/~geoff/ispell.html.</li>
<li><pkg>hunspell</pkg> provides an interface to hunspell.</li>
</ul>
<h3 id="data-in-packages">Data in Packages</h3>
<ul>
<li><pkg>lazyData</pkg> offers the ability to use data contained within packages that have not been configured using LazyData.</li>
</ul>
<h2 id="tools-and-services">Tools and Services</h2>
<h3 id="text-editors-and-ides">Text Editors and IDEs</h3>
<ul>
<li>By far the most popular <a href="https://en.wikibooks.org/wiki/R_Programming/Settings">integrated development environment (IDE)</a> for R is <a href="https://www.rstudio.com/">RStudio</a>, which is an open-source product available with both commercial and AGPL licensing. It can be run both locally and on a remote server. <pkg>rstudioapi</pkg> facilitates interaction from RStudio from within R.</li>
<li><a href="http://www.walware.de/goto/statet">StatET</a> is an R plug-in for the Eclipse IDE.</li>
<li><a href="http://ess.r-project.org/">Emacs Speaks Statistics (ESS)</a> is a feature-rich add-on package for editors like Emacs or XEmacs.</li>
</ul>
<h3 id="makefiles">Makefiles</h3>
<ul>
<li><a href="http://www.gnu.org/software/make/">GNU Make</a> is a tool that typically builds executable programs and libraries from source code by reading files called <code>Makefile</code>. It can be used to manage R package as well; <a href="https://github.com/ComputationalProteomicsUnit/maker">maker</a> is a <code>Makefile</code> completely devoted to R package development based on <a href="https://github.com/tudo-r/makeR">makeR</a>.</li>
<li><a href="https://github.com/richfitz/remake">remake</a> (not on CRAN) provides a yaml-based, Makefile-like format that can be used in Make-like workflows from within R.</li>
</ul>
<h3 id="version-control">Version Control</h3>
<ul>
<li>R itself is maintained under version control using <a href="https://subversion.apache.org/">Subversion</a>.</li>
<li>Many packages are maintained using <a href="https://git-scm.com/">git</a>, particularly those hosted on <a href="https://github.com/">GitHub</a>. <pkg>git2r</pkg> (<a href="https://github.com/ropensci/git2r">Github</a>) provides bindings to <a href="https://libgit2.github.com/">libgit2</a> for programmatic use of git within R.</li>
</ul>
<h3 id="hosting-and-package-building-services">Hosting and Package Building Services</h3>
<p>Many <a href="https://en.wikipedia.org/wiki/Comparison_of_open-source_software_hosting_facilities">hosting services</a> are available. Use of different hosts depends largely on what type of version control software is used to maintain a package. The most common sites are:</p>
<ul>
<li><a href="http://r-forge.r-project.org/">R-Forge</a>, which relies on <a href="http://subversion.apache.org/">Subversion</a>. <a href="https://rforge.net/">Rforge.net</a> is another popular Subversion-based system.</li>
<li><a href="http://log.r-hub.io/">r-hub</a> is a modern package test service funded by the RConsortium . <pkg>rhub</pkg> (<a href="https://github.com/r-hub/rhub">GitHub</a>) provides an R client for the site's API.</li>
<li><a href="https://github.com/">GitHub</a> <a href="https://help.github.com/articles/support-for-subversion-clients/">mainly</a> supports Git and Mercurial. Packages hosted on Github can be installed directly using <code>devtools::install_github()</code> or <code>remotes::install_github()</code> from <pkg>remotes</pkg>. <a href="https://github.com/r-pkgs/gh">gh</a> (not on CRAN) is a lightweight client for the GitHub API. <a href="https://github.com/jonocarroll/githubtools">githubtools</a> (not on CRAN) provides some resources for including GitHub-related links in package documentation and for analyzing packages installed from GitHub.</li>
<li><a href="https://bitbucket.org/">Bitbucket</a> is an alternative host that provides no-cost private repositories and <a href="https://about.gitlab.com/">GitLab</a> is an open source alternative. <pkg>gitlabr</pkg> provides is an API client for managing Gitlab projects.</li>
<li>Github supports <a href="https://en.wikipedia.org/wiki/Continuous_integration">continuous integration</a> for R packages. <a href="https://travis-ci.org/">Travis CI</a> is a popular continuous integration tools that supports Linux and OS X build environments. Travis has native R support, and can easily provide code coverage information via <pkg>covr</pkg> to <a href="https://codecov.io/">Codecov.io</a> or <a href="https://coveralls.io/">Coveralls</a>. <a href="https://github.com/ropenscilabs/travis">travis</a> (not on CRAN) provides an API client for Travis. Use of other CI services, such as <a href="https://circleci.com/">Circle CI</a> may require additional code and examples are available from <a href="https://github.com/craigcitro/r-travis">r-travis</a> and/or <a href="https://github.com/metacran/r-builder">r-builder</a>. <a href="https://github.com/cloudyr/circleci">circleci</a> (not on CRAN) provides an API client for Circle CI. <pkg>badgecreatr</pkg> (<a href="https://github.com/RMHogervorst/badgecreatr">GitHub</a>) provides a convenient way of creating standardized badges (or "shields") for package READMEs.</li>
<li><a href="http://win-builder.r-project.org/">WinBuilder</a> is a service intended for useRs who do not have Windows available for checking and building Windows binary packages. The package sources (after an <code>R CMD check</code>) can be uploaded via html form or passive ftp in binary mode; after checking/building a mail will be sent to the <code>Maintainer</code> with links to the package zip file and logs for download/inspection. <a href="https://www.appveyor.com/">Appveyor</a> is a continuous integration service that offers a Windows build environment. <a href="https://github.com/krlmlr/r-appveyor">r-appveyor</a> (not on CRAN) and <a href="https://github.com/cloudyr/appveyor">appveyor</a> (not on CRAN) provide API clients for Appveyor.</li>
<li><a href="https://github.com/rocker-org/rocker">Rocker</a> provides containers for use with <a href="https://www.docker.com/">Docker</a>. <a href="https://github.com/wch/harbor">harbor</a> can be used to control docker containers on remote and local hosts and <a href="https://github.com/traitecoevo/dockertest">dockertest</a> provides facilities for running tests on docker.</li>
<li>Some packages, especially some that are no longer under active development, remain hosted on <a href="https://code.google.com/">Google Code</a>. This service is closed to new projects, however, and will shut down in January 2016.</li>
<li><pkg>drat</pkg> can be used to distribute pre-built packages via Github or another server. <a href="https://github.com/ColinFay/craneur">craneur</a> (not on CRAN) provides another way of creating the same. <pkg>miniCRAN</pkg> can be used to create a subset of CRAN, for example for self-hosting of packages and their dependencies.</li>
<li>CRAN does not provide package download statistics, but the RStudio CRAN mirror does. <pkg>packagetrackr</pkg> (<a href="http://gitlab.points-of-interest.cc/points-of-interest/packagetrackr">Source</a>) facilitates downloading and analyzing those logs.</li>
</ul>
</info>
<packagelist>
<pkg priority="core">devtools</pkg>
<pkg priority="core">knitr</pkg>
<pkg priority="core">roxygen2</pkg>
<pkg>aoos</pkg>
<pkg>aprof</pkg>
<pkg>argparse</pkg>
<pkg>argparser</pkg>
<pkg>assertive</pkg>
<pkg>assertr</pkg>
<pkg>assertthat</pkg>
<pkg>available</pkg>
<pkg>backports</pkg>
<pkg>badgecreatr</pkg>
<pkg>checkmate</pkg>
<pkg>checkpoint</pkg>
<pkg>CodeDepends</pkg>
<pkg>codetools</pkg>
<pkg>commandr</pkg>
<pkg>covr</pkg>
<pkg>cranly</pkg>
<pkg>docopt</pkg>
<pkg>documair</pkg>
<pkg>drat</pkg>
<pkg>ensurer</pkg>
<pkg>fgui</pkg>
<pkg>formatR</pkg>
<pkg>FuncMap</pkg>
<pkg>functools</pkg>
<pkg>futile.logger</pkg>
<pkg>GetoptLong</pkg>
<pkg>getPass</pkg>
<pkg>git2r</pkg>
<pkg>gitlabr</pkg>
<pkg>GRANBase</pkg>
<pkg>gWidgets2</pkg>
<pkg>helloJavaWorld</pkg>
<pkg>htmlwidgets</pkg>
<pkg>hunspell</pkg>
<pkg>import</pkg>
<pkg>inline</pkg>
<pkg>inlinedocs</pkg>
<pkg>js</pkg>
<pkg>lambda.r</pkg>
<pkg>later</pkg>
<pkg>lazyData</pkg>
<pkg>lintr</pkg>
<pkg>log4r</pkg>
<pkg>logging</pkg>
<pkg>magrittr</pkg>
<pkg>matlabr</pkg>
<pkg>microbenchmark</pkg>
<pkg>miniCRAN</pkg>
<pkg>mockr</pkg>
<pkg>mvbutils</pkg>
<pkg>optigrab</pkg>
<pkg>osi</pkg>
<pkg>packagedocs</pkg>
<pkg>packagetrackr</pkg>
<pkg>packrat</pkg>
<pkg>pacman</pkg>
<pkg>pipeR</pkg>
<pkg>pkgconfig</pkg>
<pkg>pkgdown</pkg>
<pkg>pkggraph</pkg>
<pkg>pkgKitten</pkg>
<pkg>pkgmaker</pkg>
<pkg>pkgnet</pkg>
<pkg>prof.tree</pkg>
<pkg>profmem</pkg>
<pkg>profr</pkg>
<pkg>proftools</pkg>
<pkg>progress</pkg>
<pkg>proto</pkg>
<pkg>purrr</pkg>
<pkg>PythonInR</pkg>
<pkg>qtbase</pkg>
<pkg>R.methodsS3</pkg>
<pkg>R.oo</pkg>
<pkg>R6</pkg>
<pkg>rbenchmark</pkg>
<pkg>rcmdcheck</pkg>
<pkg>Rcpp</pkg>
<pkg>Rd2roxygen</pkg>
<pkg>RDocumentation</pkg>
<pkg>Rdpack</pkg>
<pkg>remotes</pkg>
<pkg>reticulate</pkg>
<pkg>rGroovy</pkg>
<pkg>rhub</pkg>
<pkg>RInside</pkg>
<pkg>rJava</pkg>
<pkg>rJython</pkg>
<pkg>rlang</pkg>
<pkg>rollbar</pkg>
<pkg>rPython</pkg>
<pkg>rscala</pkg>
<pkg>RStata</pkg>
<pkg>rstudioapi</pkg>
<pkg>rtype</pkg>
<pkg>RUnit</pkg>
<pkg>runittotestthat</pkg>
<pkg>semver</pkg>
<pkg>shiny</pkg>
<pkg>skeletor</pkg>
<pkg>sos</pkg>
<pkg>svUnit</pkg>
<pkg>sys</pkg>
<pkg>tcltk2</pkg>
<pkg>testit</pkg>
<pkg>testthat</pkg>
<pkg>unitizer</pkg>
<pkg>V8</pkg>
<pkg>vdiffr</pkg>
<pkg>withr</pkg>
<pkg>XRJulia</pkg>
</packagelist>
<links>
<a href="http://cran.r-project.org/doc/manuals/R-exts.html">[Manual] "Writing R Extension" by R-core team </a>
<a href="http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf">[Tutorial] "Creating R Packages: A Tutorial" by Friedrich Leisch </a>
<a href="http://cran.r-project.org/web/packages/httr/vignettes/api-packages.html">[Tutorial] "Best practices for writing an API package" by Hadley Wickham</a>
<a href="http://cran.r-project.org/web/packages/policies.html">[Webpage] "CRAN Repository Policy" lists rules for hosting packages on CRAN</a>
<a href="https://github.com/eddelbuettel/crp">[Webpage] Dirk Eddelbuettel provides a feed of CRAN policy changes</a>
<a href="https://github.com/jtleek/rpackages">[Webpage] "Developing R packages" by Jeff Leek</a>
<a href="http://www.springer.com/mathematics/computational+science+%26+engineering/book/978-0-387-75935-7">[Book] "Software for Data Analysis" by John Chambers</a>
<a href="http://adv-r.had.co.nz">[Book] "Advanced R" by Hadley Wickham</a>
<a href="http://r-pkgs.had.co.nz/">[Book] "R packages" by Hadley Wickham</a>
</links>
</CRANTaskView>