panabass.blogg.se

Making a package in r
Making a package in r





Standardised conventions lead to standardised tools - if you buy into R’s package conventions, you get many tools for free. They save time - you don’t need to think about the best way to organise a project, you can just follow a template. For example, you put R code in R/, you put tests in tests/ and you put data in data/. It is about saving yourself time.” Organising code in a package makes your life easier because packages come with conventions. As Hilary Parker says in her introduction to packages: “Seriously, it doesn’t have to be about sharing your code (although that is an added benefit!). If your code is in a package, any R user can easily download it, install it and learn how to use it.īut packages are useful even if you never share your code. Bundling your code into a package makes it easy for other people to use it, because like you, they already know how to use packages.

making a package in r

Why write a package? One compelling reason is that you have code that you want to share with others. The goal of this book is to teach you how to develop packages so that you can write your own, not just use other people’s.

  • You get help on them with package?x and help(package = "x").
  • You use them in R with library("x") or library(x).
  • You install them from CRAN with install.packages("x").
  • If you’re reading this book, you already know how to work with packages in the following ways:

    making a package in r

    This huge variety of packages is one of the reasons that R is so successful: the chances are that someone has already solved a problem that you’re working on, and you can benefit from their work by downloading their package. As of March 2023, there were over 19,000 packages available on the Comprehensive R Archive Network, or CRAN, the public clearing house for R packages.

    making a package in r

    A package bundles together code, data, documentation, and tests, and is easy to share with others. In R, the fundamental unit of shareable code is the package.







    Making a package in r