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)
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.
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")
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