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.
Anyone know what I'm missing? I've attached a screenshot for reference. Full disclosure: this is work for a commercial application.
I came across an error like this just now (except I had previously been able to build the package without incident).
Turns out my error was caused by a poorly formed DESCRIPTION file. Fixing the syntax there allowed my package to build.
Following is an outline of how I've approached this for a package that we'll call mypack
.
This should be the first thing you do. Update everything...
Use the roxygen2
package to create the mypack
package skeleton. From your IDE, try this:
library(roxygen2)
package.skeleton('mypack')
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][3]
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 ./man/*.Rd
(where *
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:
I recently had exactly the same problem - my package would not compile under RStudio with an error saying that the package directory does not contain the DESCRIPTION file. I solved the problem by changing encoding of the DESCRIPTION file to ANSI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With