A kitten

pkgKitten: Creating R packages that purr

So what about the kitten?

pkgKitten provides a simple alternative to the R function package.skeleton() which is most useful for creating new packages for R.

It is also very upsetting as it has been producing the same files which upset R CMD check in the exact same way.

And as something terrible happens each time R CMD check barks, this package offers a wrapper function kitten() which leaves an adorable little package behind which does not upset R CMD check.

So just think of the kittens.

Sounds intriguing. How does it work?

In the simplest case, just call `kitten()` with the name of your desired package (and in the directory you want it created). The results then tests cleanly, which sadly enough cannot be said of package.skeleton()

The package contains a demo which does just that:
library(pkgKitten)

setwd(tempdir())                        # which gets deleted anyway

kitten("simpleTest")

R <- shQuote(file.path(R.home(component="bin"), "R"))

Sys.setenv("R_TESTS"="")                # needed for R CMD check; thanks for the tip, Hadley
system(paste(R, "CMD build simpleTest"))

system(paste(R, "CMD check simpleTest_1.0.tar.gz"))

And when we run the demo, a clean check ensues as promised:
R> demo("simpleDemo", package="pkgKitten")


	demo(simpleDemo)
	---- ~~~~~~~~~~

R> library(pkgKitten)

R> setwd(tempdir())                        # which gets deleted anyway

R> kitten("simpleTest")
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './simpleTest/Read-and-delete-me'.

Adding pkgKitten overides.
Deleted 'Read-and-delete-me'.
Done.

Consider reading the documentation for all the packaging details.
A good start is the 'Writing R Extensions' manual.

And run 'R CMD check'. Run it frequently. And think of those kittens.


R> R <- shQuote(file.path(R.home(component="bin"), "R"))

R> Sys.setenv("R_TESTS"="")                # needed for R CMD check; thanks for the tip, Hadley

R> system(paste(R, "CMD build simpleTest"))
* checking for file ‘simpleTest/DESCRIPTION’ ... OK
* preparing ‘simpleTest’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building ‘simpleTest_1.0.tar.gz’


R> system(paste(R, "CMD check simpleTest_1.0.tar.gz"))
* using log directory ‘/tmp/Rtmppwn4HR/simpleTest.Rcheck’
* using R version 3.1.0 (2014-04-10)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* checking for file ‘simpleTest/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘simpleTest’ version ‘1.0* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘simpleTest’ can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking loading without being on the library search path ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking examples ... OK
* checking PDF version of manual ... OK

R>

Nice. Where does it live?

Sources for the pkgKitten package are in this pkgkitten repo. The package is also available via CRAN and its mirrors. Patches, pull requests, issue tickets etc are most welcome at the GitHub repo

Last modified: Fri Jun 13 22:46:14 CDT 2014