SlideShare a Scribd company logo
1 of 30
Download to read offline
Isabella Gollini
Isabella.Gollini@ucd.ie
@IsabellaGollini
R Package Development
Create your Own Package
DataFest Tbilisi
November 2018
https://github.com/forwards/workshops/
https://forwards.github.io
Preliminaries
The material is mostly drawn from
http://r-pkgs.had.co.nz
https://amzn.com/1491910399
The bad news:
It’s going to be
frustrating
http://hyperboleandahalf.blogspot.com/2010/09/four-levels-of-social-entrapment.html
© Allie Brosh
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/
The good news:
Frustration is
typical and
temporary
http://hyperboleandahalf.blogspot.com/2010/06/this-is-why-ill-never-be-adult.html
© Allie Brosh
Why make a package?
• You want to test
• You want to generalise
• You want to document
• You want to share
Get to know your R
installation
R.home()
list.files(R.home())
R.version
Where do R packages
come from?
CRAN and GitHub,
mostly
install.packages("foo")
library(devtools)
install_github("jane/foo")
Where do R packages
live on your computer?
R packages live
in a library
Get to know your R
library(ies?)
.Library
.libPaths() All the libraries
R knows about
The default library
.Library == .libPaths()
For many useRs, these are same
Other useRs maintain multiple libraries
E.g., You can put add-on packages in a user-level library:
/Users/isabella/resources/R/library
?
Make sure you have recent versions of
these packages
old.packages()
packageVersion()
install.packages("devtools")
install.packages("pkgdown")
install.packages("roxygen2")
install.packages("testthat")
install.packages("tidyverse")
install.packages("usethis")
My first package
# Create a package on your Desktop:
usethis::create_package("~/Desktop/mypackage")
# Or on RStudio.cloud (create within main project)
usethis::create_package("mypackage")
This will create a new R project and start a new session.
What other files and directories are created?
Your turn
What happens we run create_package()?
R/
mypackage.Rproj
DESCRIPTION
create_package("mypackage")
NAMESPACE
RStudio helpers: build (& git) menus
Package: mypackage
Version: 0.0.0.9000
Title: What the Package Does (One Line, Title Case)
Description: What the package does (one paragraph).
Authors@R: person("First", "Last", ,
"first.last@example.com", c("aut", "cre"))
License: What license it uses
Encoding: UTF-8
LazyData: true
ByteCompile: true
DESCRIPTION
Development
workflow
How is developing a
package
same / different
from developing a script?
How same?
Iterate early and often!
Change it, try it, change it, try it, ad nauseum
How different?
Write functions, not “top-level” code.
Dependencies are different,
no library() calls.
Install & Restart (or simulate that),
don’t source().
Figure from Hadley Wickham’s book, R packages
http://r-pkgs.had.co.nz
https://github.com/hadley/r-pkgs/blob/master/diagrams/installation.png
You write this … but you use this
Figure from Hadley Wickham’s book, R packages
http://r-pkgs.had.co.nz
https://github.com/hadley/r-pkgs/blob/master/diagrams/loading.png
Normal day-to-day usage
Development: Every 2 minutes
How do packages get into memory?
Development: every couple hours or days?
Install and Restart
Basic workflow
Modify code
You don’t even needto save your code!
devtools::load_all()
Cmd/Ctrl + Shift +L
Explore in console
Your turn
[Uses https://github.com/forwards/mylittlepony]
• Open mylittlepony.Rproj.
• Load all the functions using,
devtools::load_all()then run
rpony(10)
Uhoh! I have forgotten to include Fluttershy in the list
of ponies.
• Add her, reload the code, and verify that your change
worked.
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/

More Related Content

What's hot

Plugins at WordCamp Phoenix
Plugins at WordCamp PhoenixPlugins at WordCamp Phoenix
Plugins at WordCamp Phoenix
Andrew Ryno
 
Quick start website manually installing word press pdf
Quick start website manually installing word press pdfQuick start website manually installing word press pdf
Quick start website manually installing word press pdf
viet nghiem
 
The Death of Lorem Ipsum & Pixel Perfect Content
The Death of Lorem Ipsum & Pixel Perfect ContentThe Death of Lorem Ipsum & Pixel Perfect Content
The Death of Lorem Ipsum & Pixel Perfect Content
Dave Olsen
 

What's hot (20)

Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
Using composer with WordPress
Using composer with WordPressUsing composer with WordPress
Using composer with WordPress
 
Plugins at WordCamp Phoenix
Plugins at WordCamp PhoenixPlugins at WordCamp Phoenix
Plugins at WordCamp Phoenix
 
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin Development
 
Empowering Non-Profits with WordPress
Empowering Non-Profits with WordPressEmpowering Non-Profits with WordPress
Empowering Non-Profits with WordPress
 
WordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute WorkshopWordPress Plugin Development- Rich Media Institute Workshop
WordPress Plugin Development- Rich Media Institute Workshop
 
Zero To WordPress Plubish
Zero To WordPress PlubishZero To WordPress Plubish
Zero To WordPress Plubish
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016
 
How I Learned to Stop Worrying and Backup WordPress
How I Learned to Stop Worrying and Backup WordPressHow I Learned to Stop Worrying and Backup WordPress
How I Learned to Stop Worrying and Backup WordPress
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?
 
Wordpress SEO - Joost De Valk - joast
Wordpress SEO - Joost De Valk - joastWordpress SEO - Joost De Valk - joast
Wordpress SEO - Joost De Valk - joast
 
The Death of Lorem Ipsum and Pixel-Perfect Content (MinneWebCon version)
The Death of Lorem Ipsum and Pixel-Perfect Content (MinneWebCon version)The Death of Lorem Ipsum and Pixel-Perfect Content (MinneWebCon version)
The Death of Lorem Ipsum and Pixel-Perfect Content (MinneWebCon version)
 
Quick start website manually installing word press pdf
Quick start website manually installing word press pdfQuick start website manually installing word press pdf
Quick start website manually installing word press pdf
 
The Future Of WordPress Presentation
The Future Of WordPress PresentationThe Future Of WordPress Presentation
The Future Of WordPress Presentation
 
Don’t Panic: How To Troubleshoot Your WordPress Site
Don’t Panic: How To Troubleshoot Your WordPress SiteDon’t Panic: How To Troubleshoot Your WordPress Site
Don’t Panic: How To Troubleshoot Your WordPress Site
 
The Death of Lorem Ipsum & Pixel Perfect Content
The Death of Lorem Ipsum & Pixel Perfect ContentThe Death of Lorem Ipsum & Pixel Perfect Content
The Death of Lorem Ipsum & Pixel Perfect Content
 
Ember.js - Harnessing Convention Over Configuration
Ember.js - Harnessing Convention Over ConfigurationEmber.js - Harnessing Convention Over Configuration
Ember.js - Harnessing Convention Over Configuration
 
Building Headless Applications with WordPress & Gutenberg
Building Headless Applications with WordPress & GutenbergBuilding Headless Applications with WordPress & Gutenberg
Building Headless Applications with WordPress & Gutenberg
 
CakePHP mistakes made
CakePHP mistakes madeCakePHP mistakes made
CakePHP mistakes made
 

Similar to R package development, create your own package isabella gollini

Building your API utility belt (Keith Casey)
Building your API utility belt (Keith Casey)Building your API utility belt (Keith Casey)
Building your API utility belt (Keith Casey)
Future Insights
 
Rapidly Building and Deploying Scalable Web Architectures
Rapidly Building and Deploying Scalable Web ArchitecturesRapidly Building and Deploying Scalable Web Architectures
Rapidly Building and Deploying Scalable Web Architectures
Keith Fitzgerald
 
Massive paranormal dump anonymous boards 4chan-org_x_thread_13385717
Massive paranormal dump anonymous   boards 4chan-org_x_thread_13385717Massive paranormal dump anonymous   boards 4chan-org_x_thread_13385717
Massive paranormal dump anonymous boards 4chan-org_x_thread_13385717
BaddddBoyyyy
 

Similar to R package development, create your own package isabella gollini (20)

Everything you wanted to know about making an R package but were afraid to ask
Everything you wanted to know about making an R package but were afraid to askEverything you wanted to know about making an R package but were afraid to ask
Everything you wanted to know about making an R package but were afraid to ask
 
Go_ Building Web Applications ( PDFDrive.com ).pdf
Go_ Building Web Applications ( PDFDrive.com ).pdfGo_ Building Web Applications ( PDFDrive.com ).pdf
Go_ Building Web Applications ( PDFDrive.com ).pdf
 
Building your API utility belt (Keith Casey)
Building your API utility belt (Keith Casey)Building your API utility belt (Keith Casey)
Building your API utility belt (Keith Casey)
 
composer_talk_20160209
composer_talk_20160209composer_talk_20160209
composer_talk_20160209
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
PHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in phpPHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in php
 
Open event (show&tell april 2016)
Open event (show&tell april 2016)Open event (show&tell april 2016)
Open event (show&tell april 2016)
 
Atmosphere Conference 2015: The 10 Myths of DevOps
Atmosphere Conference 2015: The 10 Myths of DevOpsAtmosphere Conference 2015: The 10 Myths of DevOps
Atmosphere Conference 2015: The 10 Myths of DevOps
 
Yahoo is open to developers
Yahoo is open to developersYahoo is open to developers
Yahoo is open to developers
 
Resisting The Feature Creature
Resisting The Feature CreatureResisting The Feature Creature
Resisting The Feature Creature
 
Semantic web, python, construction industry
Semantic web, python, construction industrySemantic web, python, construction industry
Semantic web, python, construction industry
 
Beginning development in go
Beginning development in goBeginning development in go
Beginning development in go
 
Mobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B ExperimentsMobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B Experiments
 
Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in Go
 
Instagram filters
Instagram filters Instagram filters
Instagram filters
 
Rapidly Building and Deploying Scalable Web Architectures
Rapidly Building and Deploying Scalable Web ArchitecturesRapidly Building and Deploying Scalable Web Architectures
Rapidly Building and Deploying Scalable Web Architectures
 
Introduction to Groovy Monkey
Introduction to Groovy MonkeyIntroduction to Groovy Monkey
Introduction to Groovy Monkey
 
Massive paranormal dump anonymous boards 4chan-org_x_thread_13385717
Massive paranormal dump anonymous   boards 4chan-org_x_thread_13385717Massive paranormal dump anonymous   boards 4chan-org_x_thread_13385717
Massive paranormal dump anonymous boards 4chan-org_x_thread_13385717
 
Cpb2010
Cpb2010Cpb2010
Cpb2010
 
PyCourse - Self driving python course
PyCourse - Self driving python coursePyCourse - Self driving python course
PyCourse - Self driving python course
 

More from DataFest Tbilisi

More from DataFest Tbilisi (20)

Blockchain technology-in-fin tech - Anton Sitnikov
Blockchain technology-in-fin tech - Anton SitnikovBlockchain technology-in-fin tech - Anton Sitnikov
Blockchain technology-in-fin tech - Anton Sitnikov
 
Who are the 36 thousands employees of the russian defence ministry (in rus) ...
Who are the 36 thousands employees of the russian defence ministry (in rus)  ...Who are the 36 thousands employees of the russian defence ministry (in rus)  ...
Who are the 36 thousands employees of the russian defence ministry (in rus) ...
 
Using frictionless data to improve data quality - Jo Barratt
Using frictionless data to improve data quality -  Jo BarrattUsing frictionless data to improve data quality -  Jo Barratt
Using frictionless data to improve data quality - Jo Barratt
 
Using datawrapper mirko lorenz
Using datawrapper   mirko lorenzUsing datawrapper   mirko lorenz
Using datawrapper mirko lorenz
 
Securing your digital life - Jason Addie
Securing your digital life -  Jason AddieSecuring your digital life -  Jason Addie
Securing your digital life - Jason Addie
 
R package development, create package documentation isabella gollini
R package development, create package documentation   isabella golliniR package development, create package documentation   isabella gollini
R package development, create package documentation isabella gollini
 
Open data for social impact and better decision making - Denis Gursky
Open data for social impact and better decision making - Denis GurskyOpen data for social impact and better decision making - Denis Gursky
Open data for social impact and better decision making - Denis Gursky
 
Learning for sequences - Adam Mathias
Learning for sequences  - Adam MathiasLearning for sequences  - Adam Mathias
Learning for sequences - Adam Mathias
 
How to win a machine learning competition pavel pleskov
How to win a machine learning competition   pavel pleskovHow to win a machine learning competition   pavel pleskov
How to win a machine learning competition pavel pleskov
 
Defects mining in exchanges - medvedev, klimakov, yamkovi
Defects mining in exchanges - medvedev, klimakov, yamkoviDefects mining in exchanges - medvedev, klimakov, yamkovi
Defects mining in exchanges - medvedev, klimakov, yamkovi
 
Data analysis in life science vincenzo lagani
Data analysis in life science   vincenzo laganiData analysis in life science   vincenzo lagani
Data analysis in life science vincenzo lagani
 
Oddityviz: Visualizing Bowie by Miriam Quick
Oddityviz: Visualizing Bowie by Miriam QuickOddityviz: Visualizing Bowie by Miriam Quick
Oddityviz: Visualizing Bowie by Miriam Quick
 
Can data journalism save us from fake news? by Rayna Breuer
Can data journalism save us from fake news? by Rayna BreuerCan data journalism save us from fake news? by Rayna Breuer
Can data journalism save us from fake news? by Rayna Breuer
 
Losing my favourite game: how journalists are not catching up with open data ...
Losing my favourite game: how journalists are not catching up with open data ...Losing my favourite game: how journalists are not catching up with open data ...
Losing my favourite game: how journalists are not catching up with open data ...
 
What design adds to data by Mariam Kobuladze
What design adds to data by Mariam KobuladzeWhat design adds to data by Mariam Kobuladze
What design adds to data by Mariam Kobuladze
 
Feeling the data: how to build stories that people care about by Thomas burns
Feeling the data: how to build stories that people care about by Thomas burnsFeeling the data: how to build stories that people care about by Thomas burns
Feeling the data: how to build stories that people care about by Thomas burns
 
Stories vs Narratives. Using data for good. by Jakub Gornicki
Stories vs Narratives. Using data for good. by Jakub GornickiStories vs Narratives. Using data for good. by Jakub Gornicki
Stories vs Narratives. Using data for good. by Jakub Gornicki
 
The Power of Open Source Investigation by Christiaan triebert
The Power of Open Source Investigation by Christiaan triebertThe Power of Open Source Investigation by Christiaan triebert
The Power of Open Source Investigation by Christiaan triebert
 
Open data: for eveyone by everyone by Jason addie
Open data: for eveyone by everyone by Jason addieOpen data: for eveyone by everyone by Jason addie
Open data: for eveyone by everyone by Jason addie
 
Open Data Science: beyond traditional scientific communities by Alexey natekin
Open Data Science: beyond traditional scientific communities by Alexey natekinOpen Data Science: beyond traditional scientific communities by Alexey natekin
Open Data Science: beyond traditional scientific communities by Alexey natekin
 

Recently uploaded

Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
amitlee9823
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
JoseMangaJr1
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
amitlee9823
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
amitlee9823
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
amitlee9823
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
MarinCaroMartnezBerg
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
amitlee9823
 

Recently uploaded (20)

Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 

R package development, create your own package isabella gollini

  • 1. Isabella Gollini Isabella.Gollini@ucd.ie @IsabellaGollini R Package Development Create your Own Package DataFest Tbilisi November 2018 https://github.com/forwards/workshops/ https://forwards.github.io
  • 3. The material is mostly drawn from http://r-pkgs.had.co.nz https://amzn.com/1491910399
  • 4. The bad news: It’s going to be frustrating http://hyperboleandahalf.blogspot.com/2010/09/four-levels-of-social-entrapment.html © Allie Brosh
  • 5. 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/ The good news: Frustration is typical and temporary http://hyperboleandahalf.blogspot.com/2010/06/this-is-why-ill-never-be-adult.html © Allie Brosh
  • 6. Why make a package? • You want to test • You want to generalise • You want to document • You want to share
  • 7. Get to know your R installation
  • 9. Where do R packages come from?
  • 11. Where do R packages live on your computer?
  • 12. R packages live in a library
  • 13. Get to know your R library(ies?)
  • 14. .Library .libPaths() All the libraries R knows about The default library
  • 15. .Library == .libPaths() For many useRs, these are same Other useRs maintain multiple libraries E.g., You can put add-on packages in a user-level library: /Users/isabella/resources/R/library ?
  • 16. Make sure you have recent versions of these packages old.packages() packageVersion() install.packages("devtools") install.packages("pkgdown") install.packages("roxygen2") install.packages("testthat") install.packages("tidyverse") install.packages("usethis")
  • 18. # Create a package on your Desktop: usethis::create_package("~/Desktop/mypackage") # Or on RStudio.cloud (create within main project) usethis::create_package("mypackage") This will create a new R project and start a new session. What other files and directories are created? Your turn
  • 19. What happens we run create_package()? R/ mypackage.Rproj DESCRIPTION create_package("mypackage") NAMESPACE
  • 20. RStudio helpers: build (& git) menus
  • 21. Package: mypackage Version: 0.0.0.9000 Title: What the Package Does (One Line, Title Case) Description: What the package does (one paragraph). Authors@R: person("First", "Last", , "first.last@example.com", c("aut", "cre")) License: What license it uses Encoding: UTF-8 LazyData: true ByteCompile: true DESCRIPTION
  • 23. How is developing a package same / different from developing a script?
  • 24. How same? Iterate early and often! Change it, try it, change it, try it, ad nauseum
  • 25. How different? Write functions, not “top-level” code. Dependencies are different, no library() calls. Install & Restart (or simulate that), don’t source().
  • 26. Figure from Hadley Wickham’s book, R packages http://r-pkgs.had.co.nz https://github.com/hadley/r-pkgs/blob/master/diagrams/installation.png You write this … but you use this
  • 27. Figure from Hadley Wickham’s book, R packages http://r-pkgs.had.co.nz https://github.com/hadley/r-pkgs/blob/master/diagrams/loading.png Normal day-to-day usage Development: Every 2 minutes How do packages get into memory? Development: every couple hours or days? Install and Restart
  • 28. Basic workflow Modify code You don’t even needto save your code! devtools::load_all() Cmd/Ctrl + Shift +L Explore in console
  • 29. Your turn [Uses https://github.com/forwards/mylittlepony] • Open mylittlepony.Rproj. • Load all the functions using, devtools::load_all()then run rpony(10) Uhoh! I have forgotten to include Fluttershy in the list of ponies. • Add her, reload the code, and verify that your change worked.
  • 30. 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/