drat - a hands-on introduction · r cmd build somepkg dratinsert.r somepkg_1.2.3.tar.gz or directly...
TRANSCRIPT
![Page 1: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/1.jpg)
dratA Hands-On Introduction
Dirk EddelbuettelLightning TalkuseR! 2015July 1, 2015
0/14
![Page 2: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/2.jpg)
install.packages()
1/14
![Page 3: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/3.jpg)
update.packages()
2/14
![Page 4: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/4.jpg)
devtools::install_github()
3/14
![Page 5: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/5.jpg)
Repositories
Basic R infrastructure with three file system trees
· Source: src/contrib/· OS X: bin/macosx/mavericks/contrib/$VERSION· Windows: bin/windows/contrib/$VERSION
each with a PACKAGES{.gz} file.
See the drat repo for an example
4/14
![Page 6: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/6.jpg)
GitHub
Keys points:
1. Every GitHub repository has a built-in webserver2. Given repository name (i.e. drat) we just need username3. So we standardize on addRepo("username")4. And http://username.github.io/drat follows
5/14
![Page 7: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/7.jpg)
GitHub
With the repo name, and directory layout, we are done:
drat::addRepo("ghrr") # could be in ~/.Rprofile
install.package("fasttime") # install, with depends
update.packages() # or update against repos
6/14
![Page 8: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/8.jpg)
Adding to a drat
Either in the shell (here using a littler helper script)
R CMD build somePkgdratInsert.r somePkg_1.2.3.tar.gz
or directly from R
file <- devtools::build("somePkg")drat::insertPackage(file)
where both default to using ~/git/drat/ if no alternatelocation is specified
7/14
![Page 9: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/9.jpg)
Adding to a drat
· Sometimes we want private or local repos.· Use write-able directory share as 2nd argument to
insertRepo()
file <- devtools::build("somePkg")drat::insertPackage(file, "/nfs/some/dir")
· Similarly to use this local drat:
drat::addRepo("local", "file:/nfs/some/dir")
8/14
![Page 10: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/10.jpg)
Non-GitHub / Local Use
# following lines could be ~/.Rprofile or Rprofile.site# and one could also set options("repos") directlydrat::addRepo("local", "file:/nfs/some/dir")drat::addRepo("alt", "http://ourR.local") # what we do
install.package("fasttime") # install, with depends
update.packages() # or update against repos
9/14
![Page 11: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/11.jpg)
Other Topics and Use Cases
· Use drat from Travis CI (cf vignette by Colin Gillespie)· Use drat with miniCRAN (also examples by Colin)· Use drat with builder scripts (work by Rich FitzJohn et al)· Really nice direct Git(Hub) access thanks to git2r
10/14
![Page 12: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/12.jpg)
Unexpected Corrolary Benefits
11/14
![Page 13: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/13.jpg)
Unexpected Corrolary Benefits
12/14
![Page 14: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/14.jpg)
Unexpected Corrolary Benefits
13/14
![Page 15: drat - A Hands-On Introduction · R CMD build somePkg dratInsert.r somePkg_1.2.3.tar.gz or directly from R file](https://reader033.vdocument.in/reader033/viewer/2022042220/5ec5ec250ef944652c202fbe/html5/thumbnails/15.jpg)
Conclusion
· Packages are what our community is built on· (Package) Repositories are their natural habitat· R itself has everything we need to deploy repositories· GitHub a natural match for hosting (package) repositories,
with standard network storage an alternate· drat facilitates use of alternate | test | dev repos like ghrr· So let a thousand package repositories bloom!
14/14