--- title: "Stat 8054 Lecture Notes: R Packages" author: "Charles J. Geyer" date: "`r format(Sys.time(), '%B %d, %Y')`" output: html_document: number_sections: true css: "../bar.css" pdf_document: number_sections: true --- # License This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License (http://creativecommons.org/licenses/by-sa/4.0/). # R * The version of R used to make this document is `r getRversion()`. * The version of the `rmarkdown` package used to make this document is `r packageVersion("rmarkdown")`. # Reading * The book [*Writing R Extensions*](https://cloud.r-project.org/doc/manuals/r-release/R-exts.html). The whole book is relevant. Every word is needed for some R package somewhere. * Some example packages on [my GitHub account](https://github.com/cjgeyer). - R packages `foo` and `fooRegister` both in [repository `foo`](https://github.com/cjgeyer/foo). - R package `bar` in the [repo of the same name](https://github.com/cjgeyer/bar), which is also accompanied by a [gist about regression packages](https://gist.github.com/cjgeyer/2056ae760b6cf696b551a9542b73d21d). - R package `baz` in [repository `mat`](https://github.com/cjgeyer/mat). - R package `qux` in the [repo of the same name](https://github.com/cjgeyer/qux). - R package `linkingTo` in the [repo of the same name](https://github.com/cjgeyer/linkingTo). # Doing None of this actually works in Rmarkdown because it is done from the command line, not from within R. Getting a package from a Git repository ``` git clone git@github.com:cjgeyer/foo.git ``` (you may want to use a different URL `https://github.com/cjgeyer/foo.git`). Checking the package, any of ``` cd foo/package R CMD build foo R CMD check foo_*.tar.gz R CMD check foo_*.tar.gz --as-cran # should be done with R-devel R CMD check foo_*.tar.gz --use-valgrind R CMD check foo_*.tar.gz --use-gct ``` On my laptop `R CMD check --as-cran` reports a "note" > Found no calls to: ‘R_registerRoutines’, ‘R_useDynamicSymbols’ > > It is good practice to register native routines and to disable symbol search. > > See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual. This is why the package `fooRegister` exists. It does call these routines as *Writing R Extensions* suggests. Nevertheless, it seems (to the extent that the tests in the package actually *test* the package) that the package does work. When you check a package you should also read the output of examples ``` less foo.Rcheck/foo-Ex.Rout ``` and the manual ``` evince foo.Rcheck/foo-manual.pdf ```