Your SlideShare is downloading. ×
0
R PackagesQBRC Tech TalksJeff AllenJune 24, 2013
Overview• Introduction• Tools• Walkthrough• Resources
Introduction(Why should I care?)
R Packages• Share R code with another R programmer• Can be hosted in public repositories (CRAN,Bioconductor, GitHub)• Can ...
Ingredients• /R• /man• /inst• /src• DESCRIPTION• NAMESPACE
Ingredients• /R• /man• /inst• /src• DESCRIPTION• NAMESPACEOut of Scope
Ingredients• /R• /man• /inst• /src• DESCRIPTION• NAMESPACEAuto-Generated
Ingredients• /R• /man• /inst• /src• DESCRIPTION• NAMESPACEOur responsibilities
DESCRIPTIONPackage: RODProtType: PackageTitle: JSON Table Schemas from RVersion: 0.1.3Date: 2013-04-22Author: Jeffrey D. A...
Tools You’ll Want(Why this talk is only 30 minutes long.)
roxygen2• R Documentation(Rd) formato LaTeX-like, very fickleo Bad error checkinghttps://github.com/klutometis/roxygen
roxygen2• Roxygen2 is an Rpackage• Documentation is inyour R code• Compiles Rd files foryou• Integrated intoRStudio IDEhtt...
devtools• An R package• Designed to make package authorshipsimpler• Integrated into RStudio IDEhttps://github.com/hadley/d...
Walkthrough(Let’s do it!)
Steps1. Install devtools and roxygen22. Create an RStudio project with “package” buildmode.1. Set to roxygenize on all thr...
Steps9. Build and Reload10.Test & debug R code, go back to step 911.Check package before submittingo --no-manual if you do...
Resources(How do I …?)
How to Get Help• Authoritative Manualo http://cran.us.r-project.org/doc/manuals/R-exts.html• Other Presentationso http://d...
Outstanding QuestionHow to make use of other packages?
Using Other Packages• Short answer: imports• Long answer:o http://cran.r-project.org/doc/manuals/R-exts.html#Package-names...
Distribution• CRANo http://xmpalantir.wu.ac.at/cransubmit/o Are there any Errors? Warnings? Playing by the rules?• Biocond...
Tips• Study and emulate the expertso https://github.com/hadley/stringro https://github.com/yihui/knitr• Learn Roxygen2o ht...
Questions?
Upcoming SlideShare
Loading in...5
×

Creating R Packages

1,509

Published on

An overview of how to create R packages within the RStudio IDE using devtools and roxygen2.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,509
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
24
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Build & ReloadCheck--no-manual in CHECK
  • Transcript of "Creating R Packages"

    1. 1. R PackagesQBRC Tech TalksJeff AllenJune 24, 2013
    2. 2. Overview• Introduction• Tools• Walkthrough• Resources
    3. 3. Introduction(Why should I care?)
    4. 4. R Packages• Share R code with another R programmer• Can be hosted in public repositories (CRAN,Bioconductor, GitHub)• Can contain code in other languages(Fortran, C++, etc.)• In addition to code, can contain data anddocumentation
    5. 5. Ingredients• /R• /man• /inst• /src• DESCRIPTION• NAMESPACE
    6. 6. Ingredients• /R• /man• /inst• /src• DESCRIPTION• NAMESPACEOut of Scope
    7. 7. Ingredients• /R• /man• /inst• /src• DESCRIPTION• NAMESPACEAuto-Generated
    8. 8. Ingredients• /R• /man• /inst• /src• DESCRIPTION• NAMESPACEOur responsibilities
    9. 9. DESCRIPTIONPackage: RODProtType: PackageTitle: JSON Table Schemas from RVersion: 0.1.3Date: 2013-04-22Author: Jeffrey D. Allen <jeffrey.allen@utsouthwestern.edu>Maintainer: Jeffrey D. Allen <jeffrey.allen@utsouthwestern.edu>Description: An R Client for Interacting with Data Encoded inone of the Open Data Protocols Standards including JSONTable Schemas.Imports:rjson (>= 0.2.10),RCurl,License: MIT
    10. 10. Tools You’ll Want(Why this talk is only 30 minutes long.)
    11. 11. roxygen2• R Documentation(Rd) formato LaTeX-like, very fickleo Bad error checkinghttps://github.com/klutometis/roxygen
    12. 12. roxygen2• Roxygen2 is an Rpackage• Documentation is inyour R code• Compiles Rd files foryou• Integrated intoRStudio IDEhttps://github.com/klutometis/roxygen
    13. 13. devtools• An R package• Designed to make package authorshipsimpler• Integrated into RStudio IDEhttps://github.com/hadley/devtools/
    14. 14. Walkthrough(Let’s do it!)
    15. 15. Steps1. Install devtools and roxygen22. Create an RStudio project with “package” buildmode.1. Set to roxygenize on all three possibilities2. Set to build NAMESPACE, collate, and man fields3. Create a package directory4. Create an “R” directory5. Put some Roxygenized R code into “./R”6. Load/Install Devtools7. load_all()8. Fill out the description File
    16. 16. Steps9. Build and Reload10.Test & debug R code, go back to step 911.Check package before submittingo --no-manual if you don’t have pdflatex
    17. 17. Resources(How do I …?)
    18. 18. How to Get Help• Authoritative Manualo http://cran.us.r-project.org/doc/manuals/R-exts.html• Other Presentationso http://dl.dropboxusercontent.com/u/41902/easy-packages3.pdf• StackOverflowo http://stackoverflow.com/questions/tagged/ro Q & A site with active R community• Mailing Listso R-devel, Bioconductoro http://www.r-project.org/posting-guide.html#which_listo Do your research; they bite
    19. 19. Outstanding QuestionHow to make use of other packages?
    20. 20. Using Other Packages• Short answer: imports• Long answer:o http://cran.r-project.org/doc/manuals/R-exts.html#Package-namespaceso http://stackoverflow.com/questions/9893791/imports-and-dependso http://stackoverflow.com/questions/8637993/better-explanation-of-when-to-use-imports-depends• Rule of thumb: Don’t use “depends” inDESCRIPTION. There’s a better way now.
    21. 21. Distribution• CRANo http://xmpalantir.wu.ac.at/cransubmit/o Are there any Errors? Warnings? Playing by the rules?• Bioconductoro http://www.bioconductor.org/developers/package-submission/o More rigorous check, actually care about your codequality.o 6 month release cycle• GitHub*o https://github.com/o D.I.Y.* Start here
    22. 22. Tips• Study and emulate the expertso https://github.com/hadley/stringro https://github.com/yihui/knitr• Learn Roxygen2o https://github.com/klutometis/roxygen• Learn devtoolso https://github.com/hadley/devtools/• Try it at home first…o The campus proxy makes configuration more tedious
    23. 23. Questions?
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×