
It doesn’t have to necessarily have the same name as your R library. Name it something that will make it easy to find. Create a directory on your computer that will hold all the files associated with the library. Now, let’s work on creating our R library. If, for whatever reason, you need to stop partway through and have to return to a fresh R session to complete the task at a later date, repeat steps 2 and 3 before proceeding from where you left off. Then do these steps sequentially, following all directions. This tutorial is primarily aimed at users who are writing a library package based on scripts written in R.įirst, read through all of these steps. In the following, as you prepare your package, I give tips on what needs to be added where in order to ease the path towards getting your package into R CRAN. Uploading to the official R CRAN repository is a bit more work because they are very particular in how they want the package formatted (and for good reason, because they want to ensure all packages are properly documented and error free). Uploading an R library to GitHub is fairly straightforward ( see this nice tutorial here). When writing a paper, it is also a very nice touch to have your analysis code and data available to others in an R repository, and to reference that repository in the paper. Or perhaps you want to use your code and data within an RShiny application. Or perhaps you want to share your code with others. For example, perhaps you have written R methods that you use on a frequent basis, and would like an easy way to access them that would work from any computer. There are many reasons why you might want to make your own R library package. In this module, we’ll discuss how to make your own R library package, and how to upload it to the R CRAN repository.
