$30 off During Our Annual Pro Sale. View Details »

You can make a package in 20 minutes

Jim Hester
February 03, 2018

You can make a package in 20 minutes

Creating an R package can be a daunting task if you have only used R interactively, in notebooks or scripts. This talk will demystify the process creation process by going from a simple R script and turning it into a fully fledged package complete with documentation, README, examples and tests all in only twenty minutes! Along the way you will be introduced to useful functions for package development from the devtools and usethis packages, as well as the best places to find information about package development.

http://www.rstudio.com/resources/videos/you-can-make-a-package-in-20-minutes/

Jim Hester

February 03, 2018
Tweet

More Decks by Jim Hester

Other Decks in Programming

Transcript

  1. rstd.io/rp
    CAN MAKE A R IN 20 MINUTES!
    CAN MAKE A R IN 20 MINUTES!
    Jim Hester

    View Slide

  2. rstd.io/rp
    WHY WRITE R ?
    WHY WRITE R ?
    R users already know how to use / install packages
    Easy to distribute
    But…
    Can be just for you
    No need to develop personal conventions
    Standardized conventions -> standardized tools
    It does not have to go on CRAN / Bioconductor

    View Slide

  3. rstd.io/rp
    WHO CAN WRITE A PACKAGE?
    WHO CAN WRITE A PACKAGE?
    Can you open and run R / RStudio?
    Can you install a package?
    Can you write R code?
    Can you write an R function?
    Can you learn to write an R function?
    You can write a package in R
    Susan Johnston
    @SuseJohnston

    View Slide

  4. rstd.io/rp
    FOR DEVELOPMENT
    FOR DEVELOPMENT
    R packages
    Writing R Extensions
    rOpenSci Onboarding
    POSTS
    POSTS
    Writing an R package from scratch - Hilary Parker
    (@hspter)
    How to develop good R packages - Maëlle Salmon
    (@ma_salmon)
    Making your first R package - Fong Chun Chan
    (@fongchunchan)

    View Slide

  5. rstd.io/rp
    FOR DEVELOPMENT
    FOR DEVELOPMENT
    /
    /
    DEVTOOLS
    DEVTOOLS ROXYGEN2
    ROXYGEN2
    load_all() / install()
    test() / check()
    document()
    release() / rhub_check()
    USETHIS
    USETHIS
    create_package()
    use_test() / use_r()
    use_git() / use_github()
    use_travis() / use_coverage()

    View Slide

  6. rstd.io/rp
    R COMPONENTS
    R COMPONENTS
    Package metadata (DESCRIPTION)
    Code (R/)
    Testing (tests/)
    Namespaces (NAMESPACE)
    Object documentation (man/)
    Vignettes (vignettes/)
    Data (data/)
    Compiled code (src/)
    Installed files (inst/)

    View Slide

  7. rstd.io/rp
    DEMO
    DEMO

    View Slide

  8. load_all()
    test()
    document()
    check()
    create_package()
    use test()
    devtools
    usethis
    - PACKAGES
    - PACKAGES
    - GENERAL
    - GENERAL
    R packages
    Writing R Extensions
    rOpenSci Onboarding
    R for Data Science
    Advanced R

    View Slide