SlideShare a Scribd company logo
1 of 23
R Packages
QBRC Tech Talks
Jeff Allen
June 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 contain code in other languages
(Fortran, C++, etc.)
• In addition to code, can contain data and
documentation
Ingredients
• /R
• /man
• /inst
• /src
• DESCRIPTION
• NAMESPACE
Ingredients
• /R
• /man
• /inst
• /src
• DESCRIPTION
• NAMESPACE
Out of Scope
Ingredients
• /R
• /man
• /inst
• /src
• DESCRIPTION
• NAMESPACE
Auto-Generated
Ingredients
• /R
• /man
• /inst
• /src
• DESCRIPTION
• NAMESPACE
Our responsibilities
DESCRIPTION
Package: RODProt
Type: Package
Title: JSON Table Schemas from R
Version: 0.1.3
Date: 2013-04-22
Author: Jeffrey D. Allen <jeffrey.allen@utsouthwestern.edu>
Maintainer: Jeffrey D. Allen <jeffrey.allen@utsouthwestern.edu>
Description: An R Client for Interacting with Data Encoded in
one of the 'Open Data Protocols' Standards including JSON
Table Schemas.
Imports:
rjson (>= 0.2.10),
RCurl,
License: MIT
Tools You’ll Want
(Why this talk is only 30 minutes long.)
roxygen2
• R Documentation
(Rd) format
o LaTeX-like, very fickle
o Bad error checking
https://github.com/klutometis/roxygen
roxygen2
• Roxygen2 is an R
package
• Documentation is in
your R code
• Compiles Rd files for
you
• Integrated into
RStudio IDE
https://github.com/klutometis/roxygen
devtools
• An R package
• Designed to make package authorship
simpler
• Integrated into RStudio IDE
https://github.com/hadley/devtools/
Walkthrough
(Let’s do it!)
Steps
1. Install devtools and roxygen2
2. Create an RStudio project with “package” build
mode.
1. Set to roxygenize on all three possibilities
2. Set to build NAMESPACE, collate, and man fields
3. Create a package directory
4. Create an “R” directory
5. Put some Roxygenized R code into “./R”
6. Load/Install Devtools
7. load_all()
8. Fill out the description File
Steps
9. Build and Reload
10.Test & debug R code, go back to step 9
11.Check package before submitting
o --no-manual if you don’t have pdflatex
Resources
(How do I …?)
How to Get Help
• Authoritative Manual
o http://cran.us.r-project.org/doc/manuals/R-exts.html
• Other Presentations
o http://dl.dropboxusercontent.com/u/41902/easy-
packages3.pdf
• StackOverflow
o http://stackoverflow.com/questions/tagged/r
o Q & A site with active R community
• Mailing Lists
o R-devel, Bioconductor
o http://www.r-project.org/posting-guide.html#which_list
o Do your research; they bite
Outstanding Question
How 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-
namespaces
o http://stackoverflow.com/questions/9893791/imports-and-depends
o http://stackoverflow.com/questions/8637993/better-explanation-of-when-
to-use-imports-depends
• Rule of thumb: Don’t use “depends” in
DESCRIPTION. There’s a better way now.
Distribution
• CRAN
o http://xmpalantir.wu.ac.at/cransubmit/
o Are there any Errors? Warnings? Playing by the rules?
• Bioconductor
o http://www.bioconductor.org/developers/package-
submission/
o More rigorous check, actually care about your code
quality.
o 6 month release cycle
• GitHub*
o https://github.com/
o D.I.Y.
* Start here
Tips
• Study and emulate the experts
o https://github.com/hadley/stringr
o https://github.com/yihui/knitr
• Learn Roxygen2
o https://github.com/klutometis/roxygen
• Learn devtools
o https://github.com/hadley/devtools/
• Try it at home first…
o The campus proxy makes configuration more tedious
Questions?

More Related Content

What's hot

EAD, MARC and DACS
EAD, MARC and DACSEAD, MARC and DACS
EAD, MARC and DACS
millermax
 
Accessing r from python using r py2
Accessing r from python using r py2Accessing r from python using r py2
Accessing r from python using r py2
Wisdio
 
From Floras to Interactive Keys
From Floras to Interactive KeysFrom Floras to Interactive Keys
From Floras to Interactive Keys
Kehan Harman
 

What's hot (20)

Python Programming - An Introduction
Python Programming - An IntroductionPython Programming - An Introduction
Python Programming - An Introduction
 
EAD, MARC and DACS
EAD, MARC and DACSEAD, MARC and DACS
EAD, MARC and DACS
 
GNU R in Clinical Research and Evidence-Based Medicine
GNU R in Clinical Research and Evidence-Based MedicineGNU R in Clinical Research and Evidence-Based Medicine
GNU R in Clinical Research and Evidence-Based Medicine
 
rdf query reformulation
rdf query reformulationrdf query reformulation
rdf query reformulation
 
Lee.stat
Lee.statLee.stat
Lee.stat
 
Rdf
RdfRdf
Rdf
 
Introduction to EAD
Introduction to EADIntroduction to EAD
Introduction to EAD
 
Continuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master CraftContinuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master Craft
 
File carving overview
File carving overviewFile carving overview
File carving overview
 
R Brownbag Seminar 2.1
R Brownbag Seminar 2.1R Brownbag Seminar 2.1
R Brownbag Seminar 2.1
 
Advanced Code Analysis In .NET
Advanced Code Analysis In .NETAdvanced Code Analysis In .NET
Advanced Code Analysis In .NET
 
2232021 cs 265 — assignment – json dirhttpswww.cs.dre
2232021 cs 265 — assignment – json dirhttpswww.cs.dre2232021 cs 265 — assignment – json dirhttpswww.cs.dre
2232021 cs 265 — assignment – json dirhttpswww.cs.dre
 
Accessing r from python using r py2
Accessing r from python using r py2Accessing r from python using r py2
Accessing r from python using r py2
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
From Floras to Interactive Keys
From Floras to Interactive KeysFrom Floras to Interactive Keys
From Floras to Interactive Keys
 
Advanced Code Analysis with .NET
Advanced Code Analysis with .NETAdvanced Code Analysis with .NET
Advanced Code Analysis with .NET
 
Rdf In A Nutshell V1
Rdf In A Nutshell V1Rdf In A Nutshell V1
Rdf In A Nutshell V1
 
Reproducibility with Checkpoint & RRO
Reproducibility with Checkpoint & RROReproducibility with Checkpoint & RRO
Reproducibility with Checkpoint & RRO
 
Reproducible research
Reproducible researchReproducible research
Reproducible research
 
How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)
 

Viewers also liked (6)

Stories Inc. Deck
Stories Inc. DeckStories Inc. Deck
Stories Inc. Deck
 
Scientific Software Development
Scientific Software DevelopmentScientific Software Development
Scientific Software Development
 
Scientific Computing - Hardware
Scientific Computing - HardwareScientific Computing - Hardware
Scientific Computing - Hardware
 
Group meeting may 16 2013
Group meeting   may 16 2013Group meeting   may 16 2013
Group meeting may 16 2013
 
Tech talk ggplot2
Tech talk   ggplot2Tech talk   ggplot2
Tech talk ggplot2
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Similar to Creating R Packages

R Introduction
R IntroductionR Introduction
R Introduction
schamber
 
Business Analytics with R
Business Analytics with RBusiness Analytics with R
Business Analytics with R
Edureka!
 

Similar to Creating R Packages (20)

R development
R developmentR development
R development
 
R Introduction
R IntroductionR Introduction
R Introduction
 
R reproducibility
R reproducibilityR reproducibility
R reproducibility
 
R Intro
R IntroR Intro
R Intro
 
PPT - Introduction to R.pdf
PPT - Introduction to R.pdfPPT - Introduction to R.pdf
PPT - Introduction to R.pdf
 
Analysing GitHub commits with R
Analysing GitHub commits with RAnalysing GitHub commits with R
Analysing GitHub commits with R
 
Getting Started with R
Getting Started with RGetting Started with R
Getting Started with R
 
R training at Aimia
R training at AimiaR training at Aimia
R training at Aimia
 
BUSINESS ANALYTICS WITH R SOFTWARE DIAST
BUSINESS ANALYTICS WITH R SOFTWARE DIASTBUSINESS ANALYTICS WITH R SOFTWARE DIAST
BUSINESS ANALYTICS WITH R SOFTWARE DIAST
 
R introduction
R introductionR introduction
R introduction
 
Introduction to R for Data Science :: Session 1
Introduction to R for Data Science :: Session 1Introduction to R for Data Science :: Session 1
Introduction to R for Data Science :: Session 1
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible research
 
Apache Spark Usage in the Open Source Ecosystem
Apache Spark Usage in the Open Source EcosystemApache Spark Usage in the Open Source Ecosystem
Apache Spark Usage in the Open Source Ecosystem
 
Running R on Hadoop - CHUG - 20120815
Running R on Hadoop - CHUG - 20120815Running R on Hadoop - CHUG - 20120815
Running R on Hadoop - CHUG - 20120815
 
Getting started with R & Hadoop
Getting started with R & HadoopGetting started with R & Hadoop
Getting started with R & Hadoop
 
Introduction to R software, by Leire ibaibarriaga
Introduction to R software, by Leire ibaibarriaga Introduction to R software, by Leire ibaibarriaga
Introduction to R software, by Leire ibaibarriaga
 
Class ppt intro to r
Class ppt intro to rClass ppt intro to r
Class ppt intro to r
 
Apache Jena Elephas and Friends
Apache Jena Elephas and FriendsApache Jena Elephas and Friends
Apache Jena Elephas and Friends
 
Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...
Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...
Contributing to Apache Airflow | Journey to becoming Airflow's leading contri...
 
Business Analytics with R
Business Analytics with RBusiness Analytics with R
Business Analytics with R
 

Recently uploaded

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Creating R Packages

  • 1. R Packages QBRC Tech Talks Jeff Allen June 24, 2013
  • 2. Overview • Introduction • Tools • Walkthrough • Resources
  • 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 and documentation
  • 5. Ingredients • /R • /man • /inst • /src • DESCRIPTION • NAMESPACE
  • 6. Ingredients • /R • /man • /inst • /src • DESCRIPTION • NAMESPACE Out of Scope
  • 7. Ingredients • /R • /man • /inst • /src • DESCRIPTION • NAMESPACE Auto-Generated
  • 8. Ingredients • /R • /man • /inst • /src • DESCRIPTION • NAMESPACE Our responsibilities
  • 9. DESCRIPTION Package: RODProt Type: Package Title: JSON Table Schemas from R Version: 0.1.3 Date: 2013-04-22 Author: Jeffrey D. Allen <jeffrey.allen@utsouthwestern.edu> Maintainer: Jeffrey D. Allen <jeffrey.allen@utsouthwestern.edu> Description: An R Client for Interacting with Data Encoded in one of the 'Open Data Protocols' Standards including JSON Table Schemas. Imports: rjson (>= 0.2.10), RCurl, License: MIT
  • 10. Tools You’ll Want (Why this talk is only 30 minutes long.)
  • 11. roxygen2 • R Documentation (Rd) format o LaTeX-like, very fickle o Bad error checking https://github.com/klutometis/roxygen
  • 12. roxygen2 • Roxygen2 is an R package • Documentation is in your R code • Compiles Rd files for you • Integrated into RStudio IDE https://github.com/klutometis/roxygen
  • 13. devtools • An R package • Designed to make package authorship simpler • Integrated into RStudio IDE https://github.com/hadley/devtools/
  • 15. Steps 1. Install devtools and roxygen2 2. Create an RStudio project with “package” build mode. 1. Set to roxygenize on all three possibilities 2. Set to build NAMESPACE, collate, and man fields 3. Create a package directory 4. Create an “R” directory 5. Put some Roxygenized R code into “./R” 6. Load/Install Devtools 7. load_all() 8. Fill out the description File
  • 16. Steps 9. Build and Reload 10.Test & debug R code, go back to step 9 11.Check package before submitting o --no-manual if you don’t have pdflatex
  • 18. How to Get Help • Authoritative Manual o http://cran.us.r-project.org/doc/manuals/R-exts.html • Other Presentations o http://dl.dropboxusercontent.com/u/41902/easy- packages3.pdf • StackOverflow o http://stackoverflow.com/questions/tagged/r o Q & A site with active R community • Mailing Lists o R-devel, Bioconductor o http://www.r-project.org/posting-guide.html#which_list o Do your research; they bite
  • 19. Outstanding Question How to make use of other packages?
  • 20. Using Other Packages • Short answer: imports • Long answer: o http://cran.r-project.org/doc/manuals/R-exts.html#Package- namespaces o http://stackoverflow.com/questions/9893791/imports-and-depends o http://stackoverflow.com/questions/8637993/better-explanation-of-when- to-use-imports-depends • Rule of thumb: Don’t use “depends” in DESCRIPTION. There’s a better way now.
  • 21. Distribution • CRAN o http://xmpalantir.wu.ac.at/cransubmit/ o Are there any Errors? Warnings? Playing by the rules? • Bioconductor o http://www.bioconductor.org/developers/package- submission/ o More rigorous check, actually care about your code quality. o 6 month release cycle • GitHub* o https://github.com/ o D.I.Y. * Start here
  • 22. Tips • Study and emulate the experts o https://github.com/hadley/stringr o https://github.com/yihui/knitr • Learn Roxygen2 o https://github.com/klutometis/roxygen • Learn devtools o https://github.com/hadley/devtools/ • Try it at home first… o The campus proxy makes configuration more tedious

Editor's Notes

  1. Build &amp; ReloadCheck--no-manual in CHECK