From murdoch.duncan at gmail.com  Wed Jan 31 02:09:52 2018
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Tue, 30 Jan 2018 20:09:52 -0500
Subject: [Rd] Best practices in developing package: From a single file
In-Reply-To: <23152.57287.697853.990831@rob.eddelbuettel.com>
References: <CAPtbhHwLXvdCX+1PJvEAyjWtcaVf=k4kL2fgXNhxLqfBhoJg-Q@mail.gmail.com>
 <1517329742.15543.15.camel@braverock.com>
 <aef83954-b118-6f8f-6d4f-d2a9758121cc@gmail.com>
 <CY4PR2001MB10641A6B87B06111469FDBD0BEE40@CY4PR2001MB1064.namprd20.prod.outlook.com>
 <23152.57287.697853.990831@rob.eddelbuettel.com>
Message-ID: <ac51f4f1-c71e-9555-9668-10e2c880c04a@gmail.com>

On 30/01/2018 4:12 PM, Dirk Eddelbuettel wrote:
> 
> Mehmet,
> 
> That is a loaded topic, not unlikely other topics preoccupying us these days.
> 
> There is package.skeleton() in base R as you already mentioned. It drove me
> bonkers that it creates packages which then fail R CMD check, so I wrote a
> wrapper package (pkgKitten) with another helper function (kitten()) which
> calls the base R helper and then cleans up it---but otherwise remains
> faithful to it.

Failing R CMD check isn't a big deal:  you want to be reminded to edit 
those incomplete help files.  But I think I recall that you couldn't 
even build the package that package.skeleton() created, and that indeed 
would be irritating, especially if you had a lot of functions so you had 
a lot of cleanup to do.  I don't know if that's still true because I 
generally use RStudio to create the initial package structure rather 
than calling package.skeleton myself.

Duncan Murdoch

> 
> These days pkgKitten defaults to creating per-package top-level help page
> that just references content from DESCRIPTION via a set of newer Rd macros as
> I find that helps keeping them aligned. The most recent example of mine is
>    https://github.com/eddelbuettel/prrd/blob/master/man/prrd-package.Rd
> I use either this function or the RStudio template helper all the time.
> 
> And similarly, other people written similar helpers. You may get other pointers.
> 
> And every couple of months someone writes a new tutorial about how to write a
> first package. Then social media goes gaga and we get half a dozen blog posts
> where someone celebrates finding said tutorial, reading it and following
> through with a new package.
> 
> And many of us taught workshops on creating packages. There is a lot of
> material out here, though lots of this material seems to be entirely ignorant
> of what came before it.
> 
> And there has been lots, including Fritz's tutorial from a decade ago:
> 
>      https://epub.ub.uni-muenchen.de/6175/  as well as on CRAN as
>      https://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf
> 
> So I'd recommend you just experiment and set up your own helpers. After all
> the rule still holds: Anything you do more than three times should be a
> function, and every function should be in a package. So customize _your_
> function to create your package.
> 
> Dirk
>



[Rd] Best practices in developing package: From a single file
Duncan Murdoch