Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/isteves/r-pkg-intro

How to create an R package
https://github.com/isteves/r-pkg-intro

Last synced: about 2 months ago
JSON representation

How to create an R package

Awesome Lists containing this project

README

        

[![Travis-CI Build Status](https://travis-ci.org/isteves/r-pkg-intro.svg?branch=master)](https://travis-ci.org/isteves/r-pkg-intro)

# How to create an R package :package:

Check out the [slidedeck](https://isteves.github.io/r-pkg-intro/Presentation.html#/) to quickly build your first package! :palm_tree: :sunny: :ocean:

**Here's an alternate Git/RStudio workflow you can use to get your package started:**

1. Create an new GitHub repo on https://github.com/new
2. Create a new Git R project (File --> New Project --> Version Control --> Git --> [paste in Repository URL] & [Create Project])
3. Use `devtools::create(".")` to initiate a package. You can say "no" when it asks you to overwrite the RProj file.

# Other tips and resources

Also check out these guides to package development in R:

- [Writing an R package from scratch](https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/) blogpost by Hilary Parker
- [R packages](http://r-pkgs.had.co.nz/) book by Hadley Wickham
- [R packages cheatsheet](https://www.rstudio.com/wp-content/uploads/2015/03/devtools-cheatsheet.pdf)
- Official [writing R extensions](https://cran.r-project.org/doc/manuals/R-exts.html#Creating-R-packages) guide

Here are some other great **packages** you may want to check out:

- [usethis](https://github.com/r-lib/usethis)
- [goodpractice](https://github.com/MangoTheCat/goodpractice)
- [styler](https://github.com/r-lib/styler) for auto-style checking
- [lintr](https://github.com/jimhester/lintr) for style - use with Travis to auto-check your code!
- [pkgdown](https://github.com/r-lib/pkgdown) for creating a website for your package

And some **keyboard short-cuts**:

- *Cmd + i* = auto-indent
- *Cmd + opt + shift + r* = auto-generate roxygen skeleton
- *Cmd + shift + t* = `devtools::test()`
- *Cmd + shift + d* = `devtools::document()`

If you are on Windows, Use `Ctrl` in the place of `Cmd` for the above shortcuts work.

Other reading/resources:

- [Unix Design Philosophy](http://wiki.c2.com/?UnixDesignPhilosophy) - design principles to think about when designing software/etc; many points are echoed in the [R packages book](http://r-pkgs.had.co.nz/)