First install this package:
devtools::install_github('nimble-dev/nimble-devtools')
Next restart RStudio and verify that you see menu items
Tools > Addins > Hot Reload Code
and
Tools > Addins > Open Genrated C++ Files
.
To use RStudio addins, you may need to upgrade to a more recent RStudio.
If you modify an internal NIMBLE function in-place and want to reload it quickly
(without a lengthy R CMD INSTALL process), you can use our Hot Reload addin for
RStudio. (This is just a smart wrapper around assignInNamespace
.)
(optional) Set a keyboard shortcut for the hot reload addin using
Tools > Addins > Browse Addins...
. For example I use CTRL-R
.
In an RStudio editor window, position the cursor on the first line of the
definition name <- function(...){...}
of your modified NIMBLE code.
Either click on the Tools > Addins > Hot Reload Code
menu item, or use
your new keyboard shortcut.
tempdir()
(optional) Set a keyboard shortcut for the Open Generated C++ addin using
Tools > Addins > Browse Addins...
. For example I use CTRL-G
.
Generate some C++ files with compileNimble()
Either click on the Tools > Addins > Open Generated C++ Files
menu item,
or use your new keyboard shortcut.
These steps attempt to speed up R CMD build nimble && R CMD INSTALL nimble_*.tar.gz
:
(Savings: 50%) On Linux or OS X, use ccache. Following Dirk Eddelbuettel's advice, you can enable ccache globally on your system by creating symbolic links to ccache for each of the compilers you use:
{sh}
cd /usr/local/bin
sudo ln -s /usr/bin/ccache gcc
sudo ln -s /usr/bin/ccache g++
sudo ln -s /usr/bin/ccache clang
sudo ln -s /usr/bin/ccache clang++
(Savings: 25%) Add tons of --no-<expensive operation>
flags to your R CMD INSTALL invocation.
Fritz wrapped this in a script nim-install.sh in this repo.
TODO add a .bat file or something for Windows users.
Further research is needed. Fritz started to profile package installation with profile_install_nimble.R
Perry suggested the following test wrapper to run tests in a single file:
library(nimble)
library(testthat)
source(system.file(file.path('tests', 'test_utils.R'), package = 'nimble'))
if (0) options(error = recover) else options(error = NULL) # Toggle 0/1 to enable/disable recover().
# This tests the file 'tests/test-optim.R'.
test_package('nimble', 'optim', reporter = 'tap') # tap has prettier error reporting.
To quickly open the latest generated C++ files
Install clang-format so that the files can be automatically formatted. For example
{bash}
brew install clang-format # OS X
sudo apt-get install clang-format # linux
Set your EDITOR
environment variable to your favorite editor
(vim
, emacs
, sublime
, etc.)
Configure nimble to compile to the directory ~/tmp
{r}
compileNimble(myFunction, dirName = '~/tmp')
Run nim-show.py.
I've added this to my PATH
so I can type nim-sh<TAB><ENTER>
anywhere to quickly see the latest
If you're an Emacs or Vim user, you can make use of the rtags()
function to generate tags files to more quickly navigate source code.
Perry recommends the command R CMD rtags
.
This lets you jump-to-defintion of a symbol.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.