John Paul
John Paul

Reputation: 12664

How to build a package in an existing directory with RStudio

I am working on a making a package in RStudio. I already have it as a project, and I am using Git for version control. My directory structure is currently

--Project
   --R
   --.git

With the R code in the R directory.

My problem occurs when I go to build the package. I want to call the package "Project" and I get the a directory structure like this:

--Project
   --R
   --.git
   --Project
      --man
      --R

And in this setup there are two sets of R files, on in each "R" directory. The less nested one is being versioned by Git, the more nested one is the source for the package. Is there some way to get the package to just use the preexisting "R" directory? Can I just reanme my current "Project" directory to something else, make the package as "Project" and then copy the .git directory to the new Project directory?

Upvotes: 15

Views: 8232

Answers (1)

BroVic
BroVic

Reputation: 1079

In RStudio (I'm using v. 1.0.136), this can be done via the menu options Tools > Project Options > Build Tools. Select Package from the drop-down list for Project build tools, and if you know what you're doing, fill in any of the other fields as you deem appropriate.

This operation is not going to necessarily give you the structure above i.e. man and R folders or a DESCRIPTION file, which can be done with the use_description() function from the usethis package.

Upvotes: 22

Related Questions