Once you’ve created a package, you may be interested in sharing it with your friends, colleagues, collaborators, boss, and maybe any useR in the world. In this chapter I will describe a couple of ways to share your package.
16.2 File sharing
The most straighforward way to share your package is to take the bundled package (
.tar.gz file) and share it with whoever you want. Perhaps the simplest way to do this is to email the bundle file, or share it through a file-sharing service like Google Drive, Dropbox, Box, etc.
To install your package, the users will have to download it to their computers, and then install it with the function
install.packages(), specifying the path of the
.tar.gz file. Or they can also use the menu options from RStudio’s Packages tab (see screenshot below).
- Go to the Packages tab
- Click on the Install button
- Select the option Install from:
- Select Package Archive File (.tar.gz)
- Specify the location of the
- and finally click Install.
Another very convenient way to share your package is GitHub. I’m assuming that you have a GitHub account, and that you have some familiarity with this service. If you use GitHub to host your package source, the
install_github() is the way to go.
All you (or any other user) have to do is specify the GitHub username, and the name of the repository containing the source code:
You can try installing my
"cointoss" package with
install_github() like this:
this is equivalent to:
devtools::install_github("cointoss", username = "gastonstat")
If a package is in some subdirectory inside a github repository, you can also use
install_github(). Pretend that the source package is in the folder
"cointoss", inside my github repository
repo. A user sould be able to install the package running the following command:
devtools::install_github("repo", username = "gastonstat", subdir = "cointoss")
A few things to keep in mind about
devtools::install_github()allows you to install a remote package.
- it downloads a source package, builds it and then installs it.
- by default, it does not build vignettes (to save time).
- to build vignettes use
devtools::install_github(build_vignettes = TRUE).
Make a donation
If you find this resource useful, please consider making a one-time donation in any amount. Your support really matters.