This question has been asked by another user on the RStudio help page here but has gone unanswered.
Basically, I've gone through all the steps:
(1) Installed Xcode
(2) Downloaded and installed command line tools
(3) Installed MacTex
(4) Selected the directory containing the R package with accompanying description file.
This package compiled just fine on the Mac I first used to build it. Now, however, I am being told that RStudio cannot detect the DESCRIPTION file, even though it is sitting right there in the build directory. I've attached a screenshot.
The error message I get is:
ERROR: The build directory does not contain a DESCRIPTION file so cannot be built as a package.
Following is an outline of how I've approached this for a package that we'll call
This should be the first thing you do. Update everything...
roxygen2 package to create the
mypack package skeleton. From your IDE, try this:
See http://cran.r-project.org/web/packages/roxygen2/roxygen2.pdf for more details.
Edit the DESCRIPTION file using a reader that lets me see non-printing characters. It's worth checking to see if there are any odd characters hiding in your file. RStudio is a good editor to use.
Compare your DESCRIPTION file contents with someone else's github repositories, for example the
plyr description file.
Also, there's a related question here with an answer that explains some more of how the DESCRIPTION file is used.
I use a script (below) to build my package from within Rstudio, rather than using Rstudio's canned options. I don't like having to remember to switch between the usual IDE and some project.
You'll need to have
[devtools] installed to make this work.
setwd('~/Documents/projects/Rcode') # remove the old version try(detach(name = "package:mypack",unload = TRUE)) # load the packages we need for building / documentation library("roxygen2") # could use "require" # generate documentation roxygenize(package.dir = "mypack") # now we actually build and install the package system("R CMD build mypack") system("R CMD INSTALL --preclean mypack_1.00.tar.gz") system("R CMD check mypack") # check for old documentation try(file.remove(file.path(getwd(),"mypack.pdf"))) # generate new documentation system("R CMD Rd2pdf mypack") # and finally, make it available. library("mypack")
Disclaimer: I am fully aware that I may have some of the above in the wrong order, or be doing something daft. I'm just not sure what, and it works at the moment.
I have R-markdown in the headers of all of my functions, so the help files are created as
* is the function name) automagically when I execute this script. Again, have a look at the plyr github to get a feel for this.
I also wrote a vignette for this package. That's an .Rnw file, which can be edited in Rstudio or any other text editor. The .Rnw file is basically latex with embedded knitr chunks. Rstudio's editor has an option to compile this independently of the package itself. This seems to be a great solution, and the above script recompiles the vignettes whenever I update my code, which is a good check on everything.
I know this script works on multiple macs, but have never had the misfortune to have to use a windows machine to compile. A colleague of mine is using the compiled package on windows without any trouble, though.
Useful resources for this include: