SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
November 2010
Hadley Wickham
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
Making an R package
Tuesday, 9 November 2010
https://github.com/
hadley/devtools/wiki
What I’ve learned from developing 20+ R packages
Tuesday, 9 November 2010
1. Getting started
2. Development cycle
3. Documentation
4. What to learn next
W
arning:
opinionated
advice
Tuesday, 9 November 2010
Use a mac! (or linux)
Otherwise, start by downloading and installing
http://www.murdoch-sutherland.com/Rtools/
Tuesday, 9 November 2010
Getting
started
Tuesday, 9 November 2010
1. Decide on a name
(stringr)
2. Create stringr/ and
stringr/R/
directories
3. Copy in your existing
code
!"" R
#   !"" file1.r
#   !"" file2.r
Tuesday, 9 November 2010
4. Add a description file
!"" DESCRIPTION
!"" R
Tuesday, 9 November 2010
Package: stringr
Type: Package
Title: Make it easier to work with strings.
Version: 0.5
Author: Hadley Wickham <h.wickham@gmail.com>
Maintainer: Hadley Wickham <h.wickham@gmail.com>
Description: stringr is a set of simple wrappers that make R's string
functions more consistent, simpler and easier to use. It does this
by ensuring that: function and argument names (and positions) are
consistent, all functions deal with NA's and zero length character
appropriately, and the output data structures from each function
matches the input data structures of other functions.
Imports: plyr
Depends: R (>= 2.11.0)
Suggests: testthat (>= 0.3)
License: GPL-2
https://github.com/hadley/devtools/wiki/Package-basics
Tuesday, 9 November 2010
4. Document your files
5. Run roxygenize()
!"" DESCRIPTION
!"" man
!"" R
Tuesday, 9 November 2010
#' The length of a string (in characters).
#'
#' @param string input character vector
#' @return numeric vector giving number of characters in
#' each element of the character vector. Missing strings have
#' missing length.
#' @keywords character
#' @seealso code{link{nchar}} which this function wraps
#' @export
#' @examples
#' str_length(letters)
#' str_length(c("i", "like", "programming", NA))
str_length <- function(string) {
string <- check_string(string)
nc <- nchar(string, allowNA = TRUE)
is.na(nc) <- is.na(string)
nc
}
https://github.com/hadley/devtools/wiki/docs-function
Tuesday, 9 November 2010
6. Run R CMD check
7. Use R CMD build to
create a package file
8. Upload file to CRAN:
ftp -u ftp://cran.R-
project.org/incoming/
stringr_0.5.tar.gz
!"" DESCRIPTION
!"" man
!"" R
https://github.com/hadley/devtools/wiki/Release
Tuesday, 9 November 2010
You’re done!
Tuesday, 9 November 2010
Development
cycle
Tuesday, 9 November 2010
Modify and
save code
Reload in R
Does it work?
Identify the
task
Write an
automated testYES
NO
Exploratory programming
Tuesday, 9 November 2010
Confirmatory programming
Modify and
save code
Reload in R
Does it work?
Write an
automated test
YES
NO
You’re done
Tuesday, 9 November 2010
# These patterns are facilitated by the devtools
# package: https://github.com/hadley/devtools
# Once installed and set up you can easily:
# * Reload code and data
load_all("stringr")
# * Run automated tests
test("stringr")
# * Update documentation
document("stringr")
Tuesday, 9 November 2010
Documentation
Tuesday, 9 November 2010
Documentation
Function-level: gives precise details
about individual functions
Package-level: gives details about how
to use the functions to solve real
(complex) problems.
Both are essential!
Tuesday, 9 November 2010
Function-level
Keep code and documentation close
together with roxygen.
Writing documentation gets easier with
time!
Tuesday, 9 November 2010
Package-level
Package help topic
NEWS
Vignettes + CITATION
Demos
README
https://github.com/hadley/devtools/wiki/docs-package
Tuesday, 9 November 2010
Next...
Tuesday, 9 November 2010
Learning more
Testing
Namespaces
Code style
Git + github
Tuesday, 9 November 2010
Learn from others
Read the source of other packages!
https://github.com/hadley/plyr
https://github.com/hadley/stringr
https://github.com/hadley/lubridate
https://github.com/hadley/evaluate
https://github.com/hadley/reshape
Tuesday, 9 November 2010
Tuesday, 9 November 2010
This work is licensed under the Creative
Commons Attribution-Noncommercial 3.0 United
States License. To view a copy of this license,
visit http://creativecommons.org/licenses/by-nc/
3.0/us/ or send a letter to Creative Commons,
171 Second Street, Suite 300, San Francisco,
California, 94105, USA.
Tuesday, 9 November 2010

Más contenido relacionado

La actualidad más candente

Data Match Merging in SAS
Data Match Merging in SASData Match Merging in SAS
Data Match Merging in SASguest2160992
 
2 R Tutorial Programming
2 R Tutorial Programming2 R Tutorial Programming
2 R Tutorial ProgrammingSakthi Dasans
 
Working with Databases and MySQL
Working with Databases and MySQLWorking with Databases and MySQL
Working with Databases and MySQLNicole Ryan
 
Report procedure
Report procedureReport procedure
Report procedureMaanasaS
 
Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)yourbookworldanil
 
Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2izahn
 
SAS cheat sheet
SAS cheat sheetSAS cheat sheet
SAS cheat sheetAli Ajouz
 
7. Data Import – Data Export
7. Data Import – Data Export7. Data Import – Data Export
7. Data Import – Data ExportFAO
 
Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management Systempsathishcs
 
Functional dependencies in Database Management System
Functional dependencies in Database Management SystemFunctional dependencies in Database Management System
Functional dependencies in Database Management SystemKevin Jadiya
 
Functional dependency and normalization
Functional dependency and normalizationFunctional dependency and normalization
Functional dependency and normalizationVisakh V
 

La actualidad más candente (20)

Data Match Merging in SAS
Data Match Merging in SASData Match Merging in SAS
Data Match Merging in SAS
 
MYSQL
MYSQLMYSQL
MYSQL
 
Sql and Sql commands
Sql and Sql commandsSql and Sql commands
Sql and Sql commands
 
Introduction to Mysql
Introduction to MysqlIntroduction to Mysql
Introduction to Mysql
 
2 R Tutorial Programming
2 R Tutorial Programming2 R Tutorial Programming
2 R Tutorial Programming
 
Working with Databases and MySQL
Working with Databases and MySQLWorking with Databases and MySQL
Working with Databases and MySQL
 
String c
String cString c
String c
 
MySql:Introduction
MySql:IntroductionMySql:Introduction
MySql:Introduction
 
Report procedure
Report procedureReport procedure
Report procedure
 
Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)
 
Break and continue
Break and continueBreak and continue
Break and continue
 
Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2Introduction to R Graphics with ggplot2
Introduction to R Graphics with ggplot2
 
SAS cheat sheet
SAS cheat sheetSAS cheat sheet
SAS cheat sheet
 
7. Data Import – Data Export
7. Data Import – Data Export7. Data Import – Data Export
7. Data Import – Data Export
 
Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management System
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
SQL
SQLSQL
SQL
 
Functional dependencies in Database Management System
Functional dependencies in Database Management SystemFunctional dependencies in Database Management System
Functional dependencies in Database Management System
 
RDBMS concepts
RDBMS conceptsRDBMS concepts
RDBMS concepts
 
Functional dependency and normalization
Functional dependency and normalizationFunctional dependency and normalization
Functional dependency and normalization
 

Destacado

Getting to Know Your Data with R
Getting to Know Your Data with RGetting to Know Your Data with R
Getting to Know Your Data with RStephen Withington
 
Correlations, Trends, and Outliers in ggplot2
Correlations, Trends, and Outliers in ggplot2Correlations, Trends, and Outliers in ggplot2
Correlations, Trends, and Outliers in ggplot2Chris Rucker
 
Model Visualisation (with ggplot2)
Model Visualisation (with ggplot2)Model Visualisation (with ggplot2)
Model Visualisation (with ggplot2)Hadley Wickham
 
Insight Data Engineering: Open source data ingestion
Insight Data Engineering: Open source data ingestionInsight Data Engineering: Open source data ingestion
Insight Data Engineering: Open source data ingestionTreasure Data, Inc.
 
R workshop iii -- 3 hours to learn ggplot2 series
R workshop iii -- 3 hours to learn ggplot2 seriesR workshop iii -- 3 hours to learn ggplot2 series
R workshop iii -- 3 hours to learn ggplot2 seriesVivian S. Zhang
 
Analyzing Data With Python
Analyzing Data With PythonAnalyzing Data With Python
Analyzing Data With PythonSarah Guido
 
pandas - Python Data Analysis
pandas - Python Data Analysispandas - Python Data Analysis
pandas - Python Data AnalysisAndrew Henshaw
 
Machine learning in R
Machine learning in RMachine learning in R
Machine learning in Rapolol92
 

Destacado (20)

Getting to Know Your Data with R
Getting to Know Your Data with RGetting to Know Your Data with R
Getting to Know Your Data with R
 
24 modelling
24 modelling24 modelling
24 modelling
 
Correlations, Trends, and Outliers in ggplot2
Correlations, Trends, and Outliers in ggplot2Correlations, Trends, and Outliers in ggplot2
Correlations, Trends, and Outliers in ggplot2
 
16 Sequences
16 Sequences16 Sequences
16 Sequences
 
20 date-times
20 date-times20 date-times
20 date-times
 
04 Wrapup
04 Wrapup04 Wrapup
04 Wrapup
 
21 spam
21 spam21 spam
21 spam
 
Model Visualisation (with ggplot2)
Model Visualisation (with ggplot2)Model Visualisation (with ggplot2)
Model Visualisation (with ggplot2)
 
03 Conditional
03 Conditional03 Conditional
03 Conditional
 
Graphical inference
Graphical inferenceGraphical inference
Graphical inference
 
Insight Data Engineering: Open source data ingestion
Insight Data Engineering: Open source data ingestionInsight Data Engineering: Open source data ingestion
Insight Data Engineering: Open source data ingestion
 
03 Modelling
03 Modelling03 Modelling
03 Modelling
 
R workshop iii -- 3 hours to learn ggplot2 series
R workshop iii -- 3 hours to learn ggplot2 seriesR workshop iii -- 3 hours to learn ggplot2 series
R workshop iii -- 3 hours to learn ggplot2 series
 
23 data-structures
23 data-structures23 data-structures
23 data-structures
 
02 Ddply
02 Ddply02 Ddply
02 Ddply
 
01 Intro
01 Intro01 Intro
01 Intro
 
Analyzing Data With Python
Analyzing Data With PythonAnalyzing Data With Python
Analyzing Data With Python
 
Reshaping Data in R
Reshaping Data in RReshaping Data in R
Reshaping Data in R
 
pandas - Python Data Analysis
pandas - Python Data Analysispandas - Python Data Analysis
pandas - Python Data Analysis
 
Machine learning in R
Machine learning in RMachine learning in R
Machine learning in R
 

Similar a R packages

Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010Matt Aimonetti
 
How to ReadTheDocs
How to ReadTheDocsHow to ReadTheDocs
How to ReadTheDocsJohn Costa
 
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 researchAndrew Lowe
 
R Introduction
R IntroductionR Introduction
R Introductionschamber
 
Will iPython replace Bash?
Will iPython replace Bash?Will iPython replace Bash?
Will iPython replace Bash?Babel
 
Will iPython replace bash?
Will iPython replace bash?Will iPython replace bash?
Will iPython replace bash?Roberto Polli
 
Introduction to r
Introduction to rIntroduction to r
Introduction to rgslicraf
 
Sinatra: прошлое, будущее и настоящее
Sinatra: прошлое, будущее и настоящееSinatra: прошлое, будущее и настоящее
Sinatra: прошлое, будущее и настоящее.toster
 
The UNIX philosophy
The UNIX philosophyThe UNIX philosophy
The UNIX philosophyKevin Maiyo
 
Data analysis in R
Data analysis in RData analysis in R
Data analysis in RAndrew Lowe
 
Scalable Plone hosting with Amazon EC2 for Rice University's Rhaptos open lea...
Scalable Plone hosting with Amazon EC2 for Rice University's Rhaptos open lea...Scalable Plone hosting with Amazon EC2 for Rice University's Rhaptos open lea...
Scalable Plone hosting with Amazon EC2 for Rice University's Rhaptos open lea...Jazkarta, Inc.
 
If you have a problem, if no one else can help... and if you can find them, m...
If you have a problem, if no one else can help... and if you can find them, m...If you have a problem, if no one else can help... and if you can find them, m...
If you have a problem, if no one else can help... and if you can find them, m...bitcoder
 

Similar a R packages (20)

06 data
06 data06 data
06 data
 
Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010
 
How to ReadTheDocs
How to ReadTheDocsHow to ReadTheDocs
How to ReadTheDocs
 
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
 
R Introduction
R IntroductionR Introduction
R Introduction
 
Will iPython replace Bash?
Will iPython replace Bash?Will iPython replace Bash?
Will iPython replace Bash?
 
Will iPython replace bash?
Will iPython replace bash?Will iPython replace bash?
Will iPython replace bash?
 
R brownbag seminar 2.2
R brownbag seminar  2.2R brownbag seminar  2.2
R brownbag seminar 2.2
 
Rusted Ruby
Rusted RubyRusted Ruby
Rusted Ruby
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
Sinatra: прошлое, будущее и настоящее
Sinatra: прошлое, будущее и настоящееSinatra: прошлое, будущее и настоящее
Sinatra: прошлое, будущее и настоящее
 
The UNIX philosophy
The UNIX philosophyThe UNIX philosophy
The UNIX philosophy
 
Python_book.pdf
Python_book.pdfPython_book.pdf
Python_book.pdf
 
Python
PythonPython
Python
 
Python
PythonPython
Python
 
Python
PythonPython
Python
 
Data analysis in R
Data analysis in RData analysis in R
Data analysis in R
 
Scalable Plone hosting with Amazon EC2 for Rice University's Rhaptos open lea...
Scalable Plone hosting with Amazon EC2 for Rice University's Rhaptos open lea...Scalable Plone hosting with Amazon EC2 for Rice University's Rhaptos open lea...
Scalable Plone hosting with Amazon EC2 for Rice University's Rhaptos open lea...
 
If you have a problem, if no one else can help... and if you can find them, m...
If you have a problem, if no one else can help... and if you can find them, m...If you have a problem, if no one else can help... and if you can find them, m...
If you have a problem, if no one else can help... and if you can find them, m...
 
Scaling DevOps
Scaling DevOpsScaling DevOps
Scaling DevOps
 

Más de Hadley Wickham (20)

27 development
27 development27 development
27 development
 
27 development
27 development27 development
27 development
 
22 spam
22 spam22 spam
22 spam
 
19 tables
19 tables19 tables
19 tables
 
18 cleaning
18 cleaning18 cleaning
18 cleaning
 
17 polishing
17 polishing17 polishing
17 polishing
 
16 critique
16 critique16 critique
16 critique
 
15 time-space
15 time-space15 time-space
15 time-space
 
14 case-study
14 case-study14 case-study
14 case-study
 
13 case-study
13 case-study13 case-study
13 case-study
 
12 adv-manip
12 adv-manip12 adv-manip
12 adv-manip
 
11 adv-manip
11 adv-manip11 adv-manip
11 adv-manip
 
11 adv-manip
11 adv-manip11 adv-manip
11 adv-manip
 
10 simulation
10 simulation10 simulation
10 simulation
 
10 simulation
10 simulation10 simulation
10 simulation
 
09 bootstrapping
09 bootstrapping09 bootstrapping
09 bootstrapping
 
08 functions
08 functions08 functions
08 functions
 
07 problem-solving
07 problem-solving07 problem-solving
07 problem-solving
 
05 subsetting
05 subsetting05 subsetting
05 subsetting
 
04 reports
04 reports04 reports
04 reports
 

Último

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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 FresherRemote DBA Services
 
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.pptxHampshireHUG
 
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...Igalia
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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 textsMaria Levchenko
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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 RobisonAnna Loughnan Colquhoun
 
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 MenDelhi Call girls
 
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...Martijn de Jong
 
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 Processorsdebabhi2
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
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
 
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...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
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
 
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...
 
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
 

R packages

  • 1. November 2010 Hadley Wickham Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University Making an R package Tuesday, 9 November 2010
  • 2. https://github.com/ hadley/devtools/wiki What I’ve learned from developing 20+ R packages Tuesday, 9 November 2010
  • 3. 1. Getting started 2. Development cycle 3. Documentation 4. What to learn next W arning: opinionated advice Tuesday, 9 November 2010
  • 4. Use a mac! (or linux) Otherwise, start by downloading and installing http://www.murdoch-sutherland.com/Rtools/ Tuesday, 9 November 2010
  • 6. 1. Decide on a name (stringr) 2. Create stringr/ and stringr/R/ directories 3. Copy in your existing code !"" R #   !"" file1.r #   !"" file2.r Tuesday, 9 November 2010
  • 7. 4. Add a description file !"" DESCRIPTION !"" R Tuesday, 9 November 2010
  • 8. Package: stringr Type: Package Title: Make it easier to work with strings. Version: 0.5 Author: Hadley Wickham <h.wickham@gmail.com> Maintainer: Hadley Wickham <h.wickham@gmail.com> Description: stringr is a set of simple wrappers that make R's string functions more consistent, simpler and easier to use. It does this by ensuring that: function and argument names (and positions) are consistent, all functions deal with NA's and zero length character appropriately, and the output data structures from each function matches the input data structures of other functions. Imports: plyr Depends: R (>= 2.11.0) Suggests: testthat (>= 0.3) License: GPL-2 https://github.com/hadley/devtools/wiki/Package-basics Tuesday, 9 November 2010
  • 9. 4. Document your files 5. Run roxygenize() !"" DESCRIPTION !"" man !"" R Tuesday, 9 November 2010
  • 10. #' The length of a string (in characters). #' #' @param string input character vector #' @return numeric vector giving number of characters in #' each element of the character vector. Missing strings have #' missing length. #' @keywords character #' @seealso code{link{nchar}} which this function wraps #' @export #' @examples #' str_length(letters) #' str_length(c("i", "like", "programming", NA)) str_length <- function(string) { string <- check_string(string) nc <- nchar(string, allowNA = TRUE) is.na(nc) <- is.na(string) nc } https://github.com/hadley/devtools/wiki/docs-function Tuesday, 9 November 2010
  • 11. 6. Run R CMD check 7. Use R CMD build to create a package file 8. Upload file to CRAN: ftp -u ftp://cran.R- project.org/incoming/ stringr_0.5.tar.gz !"" DESCRIPTION !"" man !"" R https://github.com/hadley/devtools/wiki/Release Tuesday, 9 November 2010
  • 12. You’re done! Tuesday, 9 November 2010
  • 14. Modify and save code Reload in R Does it work? Identify the task Write an automated testYES NO Exploratory programming Tuesday, 9 November 2010
  • 15. Confirmatory programming Modify and save code Reload in R Does it work? Write an automated test YES NO You’re done Tuesday, 9 November 2010
  • 16. # These patterns are facilitated by the devtools # package: https://github.com/hadley/devtools # Once installed and set up you can easily: # * Reload code and data load_all("stringr") # * Run automated tests test("stringr") # * Update documentation document("stringr") Tuesday, 9 November 2010
  • 18. Documentation Function-level: gives precise details about individual functions Package-level: gives details about how to use the functions to solve real (complex) problems. Both are essential! Tuesday, 9 November 2010
  • 19. Function-level Keep code and documentation close together with roxygen. Writing documentation gets easier with time! Tuesday, 9 November 2010
  • 20. Package-level Package help topic NEWS Vignettes + CITATION Demos README https://github.com/hadley/devtools/wiki/docs-package Tuesday, 9 November 2010
  • 22. Learning more Testing Namespaces Code style Git + github Tuesday, 9 November 2010
  • 23. Learn from others Read the source of other packages! https://github.com/hadley/plyr https://github.com/hadley/stringr https://github.com/hadley/lubridate https://github.com/hadley/evaluate https://github.com/hadley/reshape Tuesday, 9 November 2010
  • 25. This work is licensed under the Creative Commons Attribution-Noncommercial 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/ 3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. Tuesday, 9 November 2010