adnan fiaz - welcome to the university of warwick · adnan fiaz data scientist...
TRANSCRIPT
![Page 2: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/2.jpg)
Specialise in the provision of complex analysis solutions, consulting, world class training, and application development
Organisers of a range of data science focused events and organisations
Founded in 2002
Offices in Chippenham and London
![Page 3: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/3.jpg)
• Data Scientist
• Previously @ KLM
• Like to…
– Make paper helicopters with library(SixSigma)
– Read waitbutwhy.com
![Page 4: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/4.jpg)
• Fundamental unit shareable code
• Everything (code, data, docs) in one location
• Simplify loading of code
• Facilitate reproducible analysis
![Page 5: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/5.jpg)
• Base R facilitates package building
• devtools makes it easier
• Integrates with RStudio
• Integrates with other packages (roxygen2, testthat)
![Page 6: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/6.jpg)
![Page 7: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/7.jpg)
• Minimum components
– DESCRIPTION
– R directory
– man directory
– NAMESPACE
• RStudio New Project R Package
![Page 8: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/8.jpg)
• Basic package information
• Package dependencies
• License
![Page 9: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/9.jpg)
• ALL R code
– No subdirectories
• Good practices
– One file per function but don’t go crazy
– Meaningful filenames
– Use consistent coding style
![Page 10: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/10.jpg)
• Most important part of package
• Generated with roxygen2
• Each file requires a roxygen header
• Also manages NAMESPACE file
![Page 11: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/11.jpg)
• Series of checks demanded by CRAN
• Even without CRAN still good practice
• The check with devtools:– Generates documentation
– Checks DESCRIPTION
– Checks dependencies
– Errors/Warnings/Notes
![Page 12: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/12.jpg)
• R CMD check passed?
• Ready to share package Build package
• Create single file
• Windows: RTools
• Install with install.packages
![Page 13: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/13.jpg)
• When developing package code check build install can be tedious
• To check your code changes quickly
• load_all() will source all your R code
![Page 14: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/14.jpg)
• Tests are another form of documentation
– Ensure requirements are satisfied
– Make your code robust to changes
– Track bugs
• Life made easy with testthat
![Page 15: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/15.jpg)
• Write tests
– Context
– Testcases
– Expectations
• Then run test()
![Page 16: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/16.jpg)
![Page 17: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/17.jpg)
• Track changes
• Collaborate with others
• Git/SVN/BitBucket
• Upload package directory to GitHub
![Page 18: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/18.jpg)
• Ensure that a package is checked and tested on a regular basis
• Automatically run tests / R CMD check
• Setting up Travis CI with Github
![Page 19: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/19.jpg)
• pkgdown builds package website
• Easier to read/navigate than repo or README
• pkgdown::build_site()
• Setting up GitHub Pages
![Page 20: Adnan Fiaz - Welcome to the University of Warwick · Adnan Fiaz Data Scientist afiaz@mango-solutions.com @tapundemek. Specialise in the provision of complex analysis solutions, consulting,](https://reader036.vdocuments.us/reader036/viewer/2022063000/5f0e28787e708231d43de35b/html5/thumbnails/20.jpg)
• Add data
• Add C++
• Add vignettes
• Test coverage
• http://r-pkgs.had.co.nz/
• https://www.mango-solutions.com/data-science/training/courses.html