Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a package in an existing directory with RStudio

Tags:

r

build

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?

like image 700
John Paul Avatar asked May 22 '14 18:05

John Paul


People also ask

What is a .rproj file?

When a new project is created RStudio: Creates a project file (with an . Rproj extension) within the project directory. This file contains various project options (discussed below) and can also be used as a shortcut for opening the project directly from the filesystem.


1 Answers

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.

like image 160
BroVic Avatar answered Sep 30 '22 10:09

BroVic