SlideShare a Scribd company logo
1 of 34
DevTools
Package Development
BATCH - D
GROUP - D8
Sagar Deogirkar(10547321)
Ajay (10546004)
INDEX
2
1. Introduction
2. Installing DevTool in R
3. Creating New Package
4. Package Name Checking
5. Adding New Function in Package
6. Package Files
7. Package Description
8. Function Documentation with Roxygen
9. Adding Namespace File
10. Function Import & Export with Roxygen
11. Vignette
12. Package Testing
13. Data Inclusion in Package
INTRODUCTION
3
The aim of Devtools is to make package development easier by providing
R functions that simplify common tasks.
A package is a template or set of conventions that structures your code. In
common words its the collection of several functions which makes our
task easy.
We are going to use roxygen2 for documentation and testthat for testing.
Installation
Installing DevTools in R
Installing DevTools in R
Current Version – 2.2.2
Command :
install.packages(" usethis ")
install.packages("devtools")
library(devtools)
Note: To be able to build package, we need to install latest version of
RTools. Latest Version is “Rtools35”
Link: https://cran.r-project.org/bin/windows/Rtools/ - For Windows
https://cran.r-project.org/bin/macosx/ - For Mac
5
New Package
Creating New Package in R
Creating New Package in R
Steps:
1. Go to File
2. Select New Project
3. Select New Directory
4. Select R Package
5. Enter Package Name
6. Click Create Project.
7. Automated (Hello) function will be
generated in hello.R file.
7
Creating New Package in R
• Automated files will be generated in the root directory. Including Description
file, man & folder, Namespace file & a Rproj will be created with the provided
name.
8
Adding New Function in different file
▪ We can make changes in the same function or can create a new
function in same or different file with .R extension.
9
Creating New Package in R (Alternative Method)
10
•Command- devtools::create("path/to/name")
Creating New Package in R (Alternative Method)
•Automated Package files will be generated in the root directory. Including
Description file, R folder, Namespace file & an Rproj will be created with the
provided name.
11
Creating New Package in R
How to check if the package name is available?
Steps:
1. Install package available.
2. Load library(available)
3. Check with-
available(“package name")
4. R will show if the given
package name is available on
different repository or not.
5. Accordingly name can be
changed if desired to upload on
any of the repository.
12
Package Files
14
Package Files
•Description: This file describes your
work, sets up how your package will
work with other packages, and applies
a copyright.
•MAN: It contains the documentation
for your functions, the help pages in
your package.
•Namespace: This file helps you make
your package self-contained. It won’t
interfere with other packages, and
other packages won’t interfere with it.
•Test: This folder is used to store tests
that will alert you if your code breaks.
•R: All of the R code (functions) in your
package goes in R/. A package with just
an R/ directory is still a very useful
package.
•Vignette: This is basically an online
guide for the package that help the user
of package to solve the problem.
•Data: It’s often useful to include data in
a package. If you’re releasing the
package to a broad audience, it’s a way
to provide compelling use cases for the
package’s functions.
Package Description
16
Package Description
Description file is used to show the details of a New Package
• Title should always be in title case (First letter of every word is capital)
• Author: Name of the Package Designer.
• Maintainer: Name of the package maintainer.
• Description: Describe functionality of the package.
Function
Documentation
Generating Function Documentation
with Roxygen
Function Documentation
• Automated documentation
will be created in MAN folder
with function.Rd name.
Eg: hello.Rd
• We can check default
documentation with
command- ?function name
• Eg: ?hello
18
19
Generating Function Description with Roxygen
Steps :
To make R allow to generate Documentation with
Roxygen2 -
1. Open Build
2. Choose Configure Build Tools
3. Check Generate Documentation with Roxygen
4. Choose configure and check all fields which
you want to generate with Roxygen2.
5. Write “—as-cran” in Check Package
To generate Documentation file :
1. Open Code
2. Choose Insert Roxygen Skeleton
3. It will generate tags to describe function.
4. Edit the tags and click ‘clean & rebuild’ in
Build.
20
Generating Function Description with Roxygen
Recompiling the package will
generate .Rd (documentation) file
generated using Roxygen inside
‘Man’ folder with function name.
This documentation file is read
only.
21
Important Roxygen Tags
•@param – Indicates Parameters used in a function
•@example – Indicates working example of a function.
•@return – Indicates the output of the function
•@export – Indicates where the function is exported.
•@seealso – Indicate the cross-linked documentation file.
Namespace File
The Namespace File
• The NAMESPACE file allows R packages to
communicate with one another.
• It can export your functions to make them
available to others and import functions
from other packages if you use them in
your code.
• Roxygen2 can be used to export and
import functions.
23
Function Import &
Export with Roxygen
Function Import and Export with Roxygen
• export() = Exports your functions
(@export in roxygen2).
• import() = Imports all functions from
other packages (@import).
• ImportFrom() = Imports specific functions
from a single package (@importFrom)
25
Vignette File
How to create/build a vignette folder
for our package
Vignette file
• Vignettes is basically a online guide
book/notes for your package that help the
user of your package to solve the problem .
• Vignettes are very useful for packages which
are Use to solve complex algorithm
problems.
27
Create/Build a Vignette Folder for The Package
• Before creating we need to install
Rmarkdown package.
• Command- install.packages("rmarkdown")
• Create Vignette command-
usethis::use_vignette("title of your vignette" )
28
Package Testing
Package Testing
• Command- usethis::use_testthat()
It will create “tests” folder in
package file where, test file will be
stored.
• Create a new file in
package > tests > testthat
to test the function (Here we are
testing printer function as shown
in slide 13).
• Write package test code in
test_that.
• Can use different testthat functions
to tally output.
30
Package Testing
• Command- devtools::test() Use this command to test the package.
31
Data File
Including data in Package
Data Inclusion in Package
• It’s often useful to include data in a
package if you’re releasing the package to
a broad audience.
• Command- use_data_raw() { creates data
folder in package }
• Define your data and to save your data in
package use command :
• usethis::use_data("DATA name")
33
Thank You!
34

More Related Content

What's hot

Bgoug 2019.11 building free, open-source, plsql products in cloud
Bgoug 2019.11   building free, open-source, plsql products in cloudBgoug 2019.11   building free, open-source, plsql products in cloud
Bgoug 2019.11 building free, open-source, plsql products in cloudJacek Gebal
 
NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6Kostas Saidis
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about GradleEvgeny Goldin
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersNinja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersChang W. Doh
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbtFabio Fumarola
 
Dependency management in golang
Dependency management in golangDependency management in golang
Dependency management in golangRamit Surana
 
POUG2019 - Test your PL/SQL - your database will love you
POUG2019 - Test your PL/SQL - your database will love youPOUG2019 - Test your PL/SQL - your database will love you
POUG2019 - Test your PL/SQL - your database will love youJacek Gebal
 
POUG Meetup 1st MArch 2019 - utPLSQL v3 - Testing Framework for PL/SQL
POUG Meetup 1st MArch 2019 - utPLSQL v3 - Testing Framework for PL/SQLPOUG Meetup 1st MArch 2019 - utPLSQL v3 - Testing Framework for PL/SQL
POUG Meetup 1st MArch 2019 - utPLSQL v3 - Testing Framework for PL/SQLJacek Gebal
 
Jenkins Shared Libraries
Jenkins Shared LibrariesJenkins Shared Libraries
Jenkins Shared LibrariesXPeppers
 
Continuous Delivery w projekcie Open Source - Marcin Stachniuk - DevCrowd 2017
Continuous Delivery w projekcie Open Source - Marcin Stachniuk - DevCrowd 2017Continuous Delivery w projekcie Open Source - Marcin Stachniuk - DevCrowd 2017
Continuous Delivery w projekcie Open Source - Marcin Stachniuk - DevCrowd 2017MarcinStachniuk
 
CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)Soshi Nemoto
 
PuppetConf 2016: Puppet on Windows – Nicolas Corrarello, Puppet
PuppetConf 2016: Puppet on Windows – Nicolas Corrarello, PuppetPuppetConf 2016: Puppet on Windows – Nicolas Corrarello, Puppet
PuppetConf 2016: Puppet on Windows – Nicolas Corrarello, PuppetPuppet
 

What's hot (17)

Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Gradle in 45min
Gradle in 45minGradle in 45min
Gradle in 45min
 
Bgoug 2019.11 building free, open-source, plsql products in cloud
Bgoug 2019.11   building free, open-source, plsql products in cloudBgoug 2019.11   building free, open-source, plsql products in cloud
Bgoug 2019.11 building free, open-source, plsql products in cloud
 
NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6
 
5.node js
5.node js5.node js
5.node js
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about Gradle
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersNinja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for Beginners
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
Dependency management in golang
Dependency management in golangDependency management in golang
Dependency management in golang
 
POUG2019 - Test your PL/SQL - your database will love you
POUG2019 - Test your PL/SQL - your database will love youPOUG2019 - Test your PL/SQL - your database will love you
POUG2019 - Test your PL/SQL - your database will love you
 
POUG Meetup 1st MArch 2019 - utPLSQL v3 - Testing Framework for PL/SQL
POUG Meetup 1st MArch 2019 - utPLSQL v3 - Testing Framework for PL/SQLPOUG Meetup 1st MArch 2019 - utPLSQL v3 - Testing Framework for PL/SQL
POUG Meetup 1st MArch 2019 - utPLSQL v3 - Testing Framework for PL/SQL
 
Jenkins Shared Libraries
Jenkins Shared LibrariesJenkins Shared Libraries
Jenkins Shared Libraries
 
ABCs of docker
ABCs of dockerABCs of docker
ABCs of docker
 
Docker & ci
Docker & ciDocker & ci
Docker & ci
 
Continuous Delivery w projekcie Open Source - Marcin Stachniuk - DevCrowd 2017
Continuous Delivery w projekcie Open Source - Marcin Stachniuk - DevCrowd 2017Continuous Delivery w projekcie Open Source - Marcin Stachniuk - DevCrowd 2017
Continuous Delivery w projekcie Open Source - Marcin Stachniuk - DevCrowd 2017
 
CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)
 
PuppetConf 2016: Puppet on Windows – Nicolas Corrarello, Puppet
PuppetConf 2016: Puppet on Windows – Nicolas Corrarello, PuppetPuppetConf 2016: Puppet on Windows – Nicolas Corrarello, Puppet
PuppetConf 2016: Puppet on Windows – Nicolas Corrarello, Puppet
 

Similar to DevTools Package Development

Introduction to package manager
Introduction to package managerIntroduction to package manager
Introduction to package manageryashobantabai
 
How to install & update R packages?
How to install & update R packages?How to install & update R packages?
How to install & update R packages?Rsquared Academy
 
R Programming: Introduction To R Packages
R Programming: Introduction To R PackagesR Programming: Introduction To R Packages
R Programming: Introduction To R PackagesRsquared Academy
 
Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Justin James
 
The Ring programming language version 1.10 book - Part 91 of 212
The Ring programming language version 1.10 book - Part 91 of 212The Ring programming language version 1.10 book - Part 91 of 212
The Ring programming language version 1.10 book - Part 91 of 212Mahmoud Samir Fayed
 
How to Build Package in Linux Based Systems.
How to Build Package in Linux Based Systems.How to Build Package in Linux Based Systems.
How to Build Package in Linux Based Systems.İbrahim UÇAR
 
Understanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesUnderstanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesJ S Jodha
 
Unit4 java
Unit4 javaUnit4 java
Unit4 javamrecedu
 
The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.6 book - Part 7 of 189The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.6 book - Part 7 of 189Mahmoud Samir Fayed
 
Releasing and deploying python tools
Releasing and deploying python toolsReleasing and deploying python tools
Releasing and deploying python toolsQuintagroup
 
How to make debian package from scratch (linux)
How to make debian package from scratch (linux)How to make debian package from scratch (linux)
How to make debian package from scratch (linux)Thierry Gayet
 
DEF CON 27 - workshop - ISAAC EVANS - discover exploit and eradicate entire v...
DEF CON 27 - workshop - ISAAC EVANS - discover exploit and eradicate entire v...DEF CON 27 - workshop - ISAAC EVANS - discover exploit and eradicate entire v...
DEF CON 27 - workshop - ISAAC EVANS - discover exploit and eradicate entire v...Felipe Prado
 

Similar to DevTools Package Development (20)

Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Introduction to package manager
Introduction to package managerIntroduction to package manager
Introduction to package manager
 
How to install & update R packages?
How to install & update R packages?How to install & update R packages?
How to install & update R packages?
 
R Programming: Introduction To R Packages
R Programming: Introduction To R PackagesR Programming: Introduction To R Packages
R Programming: Introduction To R Packages
 
Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...
 
The Ring programming language version 1.10 book - Part 91 of 212
The Ring programming language version 1.10 book - Part 91 of 212The Ring programming language version 1.10 book - Part 91 of 212
The Ring programming language version 1.10 book - Part 91 of 212
 
How to Build Package in Linux Based Systems.
How to Build Package in Linux Based Systems.How to Build Package in Linux Based Systems.
How to Build Package in Linux Based Systems.
 
Understanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesUnderstanding NuGet implementation for Enterprises
Understanding NuGet implementation for Enterprises
 
Django
DjangoDjango
Django
 
Unit4 java
Unit4 javaUnit4 java
Unit4 java
 
R brownbag seminar 2.2
R brownbag seminar  2.2R brownbag seminar  2.2
R brownbag seminar 2.2
 
Getting Started with R
Getting Started with RGetting Started with R
Getting Started with R
 
Readme
ReadmeReadme
Readme
 
The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.6 book - Part 7 of 189The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.6 book - Part 7 of 189
 
Releasing and deploying python tools
Releasing and deploying python toolsReleasing and deploying python tools
Releasing and deploying python tools
 
How to make debian package from scratch (linux)
How to make debian package from scratch (linux)How to make debian package from scratch (linux)
How to make debian package from scratch (linux)
 
DEF CON 27 - workshop - ISAAC EVANS - discover exploit and eradicate entire v...
DEF CON 27 - workshop - ISAAC EVANS - discover exploit and eradicate entire v...DEF CON 27 - workshop - ISAAC EVANS - discover exploit and eradicate entire v...
DEF CON 27 - workshop - ISAAC EVANS - discover exploit and eradicate entire v...
 
5. react native-package
5. react native-package5. react native-package
5. react native-package
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
 

Recently uploaded

Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 

Recently uploaded (20)

Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
Russian Call Girls Dwarka Sector 15 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...
Russian Call Girls Dwarka Sector 15 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...Russian Call Girls Dwarka Sector 15 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...
Russian Call Girls Dwarka Sector 15 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 

DevTools Package Development

  • 1. DevTools Package Development BATCH - D GROUP - D8 Sagar Deogirkar(10547321) Ajay (10546004)
  • 2. INDEX 2 1. Introduction 2. Installing DevTool in R 3. Creating New Package 4. Package Name Checking 5. Adding New Function in Package 6. Package Files 7. Package Description 8. Function Documentation with Roxygen 9. Adding Namespace File 10. Function Import & Export with Roxygen 11. Vignette 12. Package Testing 13. Data Inclusion in Package
  • 3. INTRODUCTION 3 The aim of Devtools is to make package development easier by providing R functions that simplify common tasks. A package is a template or set of conventions that structures your code. In common words its the collection of several functions which makes our task easy. We are going to use roxygen2 for documentation and testthat for testing.
  • 5. Installing DevTools in R Current Version – 2.2.2 Command : install.packages(" usethis ") install.packages("devtools") library(devtools) Note: To be able to build package, we need to install latest version of RTools. Latest Version is “Rtools35” Link: https://cran.r-project.org/bin/windows/Rtools/ - For Windows https://cran.r-project.org/bin/macosx/ - For Mac 5
  • 7. Creating New Package in R Steps: 1. Go to File 2. Select New Project 3. Select New Directory 4. Select R Package 5. Enter Package Name 6. Click Create Project. 7. Automated (Hello) function will be generated in hello.R file. 7
  • 8. Creating New Package in R • Automated files will be generated in the root directory. Including Description file, man & folder, Namespace file & a Rproj will be created with the provided name. 8
  • 9. Adding New Function in different file ▪ We can make changes in the same function or can create a new function in same or different file with .R extension. 9
  • 10. Creating New Package in R (Alternative Method) 10 •Command- devtools::create("path/to/name")
  • 11. Creating New Package in R (Alternative Method) •Automated Package files will be generated in the root directory. Including Description file, R folder, Namespace file & an Rproj will be created with the provided name. 11
  • 12. Creating New Package in R How to check if the package name is available? Steps: 1. Install package available. 2. Load library(available) 3. Check with- available(“package name") 4. R will show if the given package name is available on different repository or not. 5. Accordingly name can be changed if desired to upload on any of the repository. 12
  • 14. 14 Package Files •Description: This file describes your work, sets up how your package will work with other packages, and applies a copyright. •MAN: It contains the documentation for your functions, the help pages in your package. •Namespace: This file helps you make your package self-contained. It won’t interfere with other packages, and other packages won’t interfere with it. •Test: This folder is used to store tests that will alert you if your code breaks. •R: All of the R code (functions) in your package goes in R/. A package with just an R/ directory is still a very useful package. •Vignette: This is basically an online guide for the package that help the user of package to solve the problem. •Data: It’s often useful to include data in a package. If you’re releasing the package to a broad audience, it’s a way to provide compelling use cases for the package’s functions.
  • 16. 16 Package Description Description file is used to show the details of a New Package • Title should always be in title case (First letter of every word is capital) • Author: Name of the Package Designer. • Maintainer: Name of the package maintainer. • Description: Describe functionality of the package.
  • 18. Function Documentation • Automated documentation will be created in MAN folder with function.Rd name. Eg: hello.Rd • We can check default documentation with command- ?function name • Eg: ?hello 18
  • 19. 19 Generating Function Description with Roxygen Steps : To make R allow to generate Documentation with Roxygen2 - 1. Open Build 2. Choose Configure Build Tools 3. Check Generate Documentation with Roxygen 4. Choose configure and check all fields which you want to generate with Roxygen2. 5. Write “—as-cran” in Check Package To generate Documentation file : 1. Open Code 2. Choose Insert Roxygen Skeleton 3. It will generate tags to describe function. 4. Edit the tags and click ‘clean & rebuild’ in Build.
  • 20. 20 Generating Function Description with Roxygen Recompiling the package will generate .Rd (documentation) file generated using Roxygen inside ‘Man’ folder with function name. This documentation file is read only.
  • 21. 21 Important Roxygen Tags •@param – Indicates Parameters used in a function •@example – Indicates working example of a function. •@return – Indicates the output of the function •@export – Indicates where the function is exported. •@seealso – Indicate the cross-linked documentation file.
  • 23. The Namespace File • The NAMESPACE file allows R packages to communicate with one another. • It can export your functions to make them available to others and import functions from other packages if you use them in your code. • Roxygen2 can be used to export and import functions. 23
  • 24. Function Import & Export with Roxygen
  • 25. Function Import and Export with Roxygen • export() = Exports your functions (@export in roxygen2). • import() = Imports all functions from other packages (@import). • ImportFrom() = Imports specific functions from a single package (@importFrom) 25
  • 26. Vignette File How to create/build a vignette folder for our package
  • 27. Vignette file • Vignettes is basically a online guide book/notes for your package that help the user of your package to solve the problem . • Vignettes are very useful for packages which are Use to solve complex algorithm problems. 27
  • 28. Create/Build a Vignette Folder for The Package • Before creating we need to install Rmarkdown package. • Command- install.packages("rmarkdown") • Create Vignette command- usethis::use_vignette("title of your vignette" ) 28
  • 30. Package Testing • Command- usethis::use_testthat() It will create “tests” folder in package file where, test file will be stored. • Create a new file in package > tests > testthat to test the function (Here we are testing printer function as shown in slide 13). • Write package test code in test_that. • Can use different testthat functions to tally output. 30
  • 31. Package Testing • Command- devtools::test() Use this command to test the package. 31
  • 33. Data Inclusion in Package • It’s often useful to include data in a package if you’re releasing the package to a broad audience. • Command- use_data_raw() { creates data folder in package } • Define your data and to save your data in package use command : • usethis::use_data("DATA name") 33

Editor's Notes

  1. Devtools wont get loaded in R script until “usethis” package is installed in R.
  2. Package name should not include symbols. Lower case is preferred. Hello function will appear. All Function files will be automatically created in R Folder.
  3. Note: with this method automated function will not be generated.
  4. Roxygen helps to make documentation and code (functions) in one place. 1. Checking all the option in configure will generate all files using Roxygen. 2. Writing “—as-cran” in check Package window will able to check package in cran. 3. While choosing “Insert Roxygen Skeleton” make sure the cursor is inside the function. 4. If existing .Rd (in MAN folder) and Namespace files are present then R will show error as ‘the files are already present and can’t be overwritten’ when ‘clean and rebuild’ after entering all documentation details.