Package for local development of all things R in VEuPathDB.
Let's say we wanted to work on the veupathUtils package.
- Clone the
veupathUtils
in this directory, so that the final organization looks like
R-local-dev
├──veupathUtils
├──Dockerfile
├──Makefile
└── ...
- Run
make build
to build the docker image that contains all packages necessary for development. - Run
make start-shell
to start an interactive R session within the development container. R should start automatically and the output should end with something like the following
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
>
Alternatively, to start RStudio run
docker run -d -p 8787:8787 -e PASSWORD=password -v $PWD:/home/rstudio rdev:dev
This will start an RStudio session. If the browser does not open automatically, navigate to http://localhost:8787/
. If you already have RStudio running locally on your machine, you can map a different port, e.g. -p 8888:8787
and access using http://localhost:8888/
.
- Now we're ready to load our package. The function
loadDevPackages
will both load the package of interest and install VEuPath dependencies if they exist. If we want to work on veupathUtils, for example, run
loadDevPackages('veupathUtils')
- Make changes to the package, reload changes with
load_all('veupathUtils')
- Once you're happy with the changes, run all the tests (defined in the
tests/testthat
folder of any package) using
devtools::test('veupathUtils')
Alternatively, run all the tests in a particular file (for example 'test-correlation.R') using
testthat::test_file('veupathUtils/tests/testthat/test-correlation.R')
- All done? Quit using
quit()
.