The main differences between a source package and an uncompressed bundle are: You could unpack such a bundle in the shell (not the R console) like so:įigure 3.1: Package forms: source vs. bundled vs. binary. Continuing our examples from above, you could download the bundles forcats_0.4.0.tar.gz and readxl_1.3.1.tar.gz (or whatever the current versions may be). tar.gz file and this is why we’ve elected to refer to this form as a package bundle, in this book.Įvery CRAN package is available in bundled form, via the “Package source” field of its landing page. By convention, in the R world, a few more operations are carried out when making the. This should tip you off that a package bundle or “source tarball” is not simply the result of making a tar archive of the source files, then compressing with gzip. Under the hood, this calls pkgbuild::build() and, ultimately, R CMD build, which is described further in the Building package tarballs section of Writing R Extensions. In the rare case that you need to make a bundle from a package you’re developing locally, use devtools::build(). While a bundle is not that useful on its own, it’s a platform-agnostic, transportation-friendly intermediary between a source package and an installed package. This means that multiple files have been reduced to a single file (. tar.gz and are sometimes referred to as “source tarballs”. By convention (from Linux), package bundles in R use the extension. 3.3 Bundled packageĪ bundled package is a package that’s been compressed into a single file. This presents a redacted view of the package and its history, but, by definition, it includes everything that is essential. Note that exploring a package’s source and history within the cran GitHub organisation is not the same as exploring the package’s true development venue, because this source and its evolution is just reverse-engineered from the package’s CRAN releases. Some maintainers forget to list this URL, even though the package is developed in a public repository, but you still might be able to discover it via search.Įven if a package is not developed on a public platform, you can visit its source in the unofficial, read-only mirror maintained by R-hub. The best case scenario is that you visit the package’s CRAN landing page, e.g.:Īnd one of its URLs links to a repository on a public hosting service, e.g.: Many R packages are developed in the open on GitHub (or GitLab or similar). The easiest way to see a package in source form right away is to browse around its code on the web. If you are new to package development, you may have never seen a package in source form! You might not even have any source packages on your computer. Most of the remaining chapters in this book are dedicated to detailing these components. It includes particular components, such as a DESCRIPTION file, an R/ directory containing. 3.2 Source packageĪ source package is just a directory of files with a specific structure. The library() function loads an installed package into memory, making it available for immediate and direct use. devtools::install_github() takes a source package on GitHub and moves it into the installed state. For example, install.packages() can move a package from the source, bundled, or binary states into the installed state. You already know some of the functions that put packages into these states. Package development workflows make much more sense if you understand the five states an R package can be in: This is NOT the package form you are most familiar with from day-to-day usage. You interact with the in-development package in its source form. When you create or modify a package, you work on its “source code” or “source files”. You’ll learn about the various states a package can be in and the difference between a package and library (and why you should care). This chapter will start you on the road to package development by converting the implicit knowledge you’ve gained from using R packages into the explicit knowledge needed to create and modify them.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |