Abstract
You now know how to write functions and create classes in R, but neither functions nor classes is the unit you use for collecting and distributing R code. That unit is the package.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
man stands for manual and the abbreviation man is a legacy from UNIX.
- 2.
e.g., vignettes/ for documentation vignettes, data/ for data you want to include with your package, and src/ for C/C++ extensions.
- 3.
CRAN is the official depository for R package and the place where the install.packages function finds them.
- 4.
There are a few more fields, such as for linking to external C/C++ code, but these three fields are the most important ones.
- 5.
Strictly speaking, this is not true. You can actually get to internal functions if you use the ::: operator instead of the :: operator. So if function_name is not exported but still implemented in the test package, you can access it with test:::function_name. But you shouldn’t. You should keep your damned dirty paws away from internal functions!
- 6.
It is also used to import selected functions or packages, but using Roxygen’s @import and @importFrom functions are better solutions for that.
- 7.
Except through the ::: operator, of course, but people who use this to access the internals of your package knows – or should know – that they are accessing implementation details that could change in the future so it is their own fault if their code is broken sometime down the line.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2017 Thomas Mailund
About this chapter
Cite this chapter
Mailund, T. (2017). Building an R Package. In: Beginning Data Science in R. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-2671-1_11
Download citation
DOI: https://doi.org/10.1007/978-1-4842-2671-1_11
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-2670-4
Online ISBN: 978-1-4842-2671-1
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)