Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When developing an R package, do I have to recompile the package every time I make a change?

I am developing a package in R

When I am debugging a particular function or set of functions, what is the best way to test the function?

Do I have to either use source('function.R') or R CMD build each time I want to check my changes?

(extra credit for associated emacs ess key-bindings)

like image 561
David LeBauer Avatar asked Oct 29 '10 20:10

David LeBauer


People also ask

How do I compile R package in RStudio?

Open a new project in RStudio. Go to the 'File' menu and click on 'New Project. ' Then select 'New Directory,' and 'R Package' to create a new R package.


1 Answers

See also http://github.com/hadley/devtools/ which provides some tools to make this task easier.

for example, after making changes to source code, you build, install, and reload a package with the function install():

library(devtools)
install("package_name")

devtools also makes it easier to:

  • Reload complete package:

    load_all("pkg")
    
  • Create or update documentation using roxygen2

    document("pkg")
    
  • run all scripts in /inst/test/:

    test("pkg")
    
  • build and R CMD check:

    check("pkg")
    
like image 110
hadley Avatar answered Sep 19 '22 04:09

hadley