Skip to content

Building the project

Alison Appling edited this page Oct 23, 2017 · 7 revisions

Initial Setup

Clone the visualization repository. You can do this in RStudio by choosing File | New Project... | Version Control | Git and pasting in the Repository URL you copied from GitHub (green "Clone or download" button).

If you don't have it, install vizlab. If the project has a specific tagged version of vizlab, you can install this using devtools::install_github("USGS-VIZLAB/vizlab@tagname").

do:

library(vizlab)
createProfile()
createMakefiles()

createProfile() may not be necessary if you've worked on vizlab before.

then make sure you have the proper packages and versions installed with:

vizlab::checkVizPackages()

and use install.packages() or devtools::install_github() to update.

To get the svglite package, use devtools::install_github("jread-usgs/svglite@svgnano"). For Windows users, you might see an error similar to Error: running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD config CC' had status 127. If this is the case, clone Jordan Read's repository and build the package locally on the branch svgnano.

Building

Go to the "Build" tab in RStudio. If you don't see the "Build" tab yet, restart RStudio. On that tab you should see a "Build All" option. Click it!

If there are errors, logs with errors are in .hurricane-irma/vizlab/make/log. You can often open these using

full_log <- getLog('item-name')

Once you are able to complete the build, see https://github.com/USGS-VIZLAB/vizlab/wiki/Previewing-visualizations to view the results.

While developing vizlab

If you've updated the vizlab package and want to try the new code in an open R session for a vizzy, run

detach("package:vizlab", unload = TRUE)
library(vizlab)

and the new code will then be available.

Debugging with remake

Vizlab allows you to build individual viz items at the R console by calling the phase-specific function on the viz item:

fetch('iris-data')
process('cuyahoga')

With remake, you will also soon be able to call vizmake on any viz item and/or its file location. The difference between calling vizmake and, say, process is that vizmake will build any out-of-date upstream dependencies first.

vizmake('data/iris.csv')
vizmake('iris-data') # coming soon

If it's a data file, you can then call readData on the file name to bring the data into R for inspection.

dat <- readData('iris-data')

When debugging functions within the R or remake systems, you have two good options. You can insert this line within the function you want to debug:

browser()

or you can tell R to debug a specific function and then run vizmake, publish, etc. as usual:

debug(vizlab:::visualize.qTDS)
visualize('cuyahogaFig') # or:
vizmake('cuyahogaFig')

and then when you're done debugging:

undebug(vizlab:::visualize.qTDS)
Clone this wiki locally