plotSpectraJS {ChemoSpec} | R Documentation |
Plot a Spectra Object Interactively
Description
This function uses the d3.js JavaScript library by Mike Bostock to plot a Spectra
object interactively. This is most useful for data exploration. For high
quality plots, consider plotSpectra
.
Usage
plotSpectraJS(spectra, which = NULL, browser = NULL, minify = TRUE)
Arguments
spectra |
An object of S3 class |
which |
Integer. If not |
browser |
Character. Something that will make sense to your OS. Only
necessary if you want to override your system specified browser as
understood by |
minify |
Logical. Shall the JavaScript be minified? This improves
performance. However, it requires package |
Details
The spectral data are incorporated into the web page. Keep in mind that very large
data sets, like NMR spectra with 32K points, will bog down the browser.
In these cases, you may need to limit the number of samples in passed to this function.
See removeSample
or use argument which
.
Value
None; side effect is an interactive web page. The temporary directory containing the files that drive the web page is written to the console in case you wish to use those files. This directory is deleted when you quit R. If you wish to read the file, don't minify the code, it will be unreadable.
Browser Choice
The browser is called by
browseURL
, which
in turn uses options("browser")
. Exactly how this is handled
is OS dependent.
RStudio Viewer
If browser is NULL
, you are using RStudio, and a
viewer is specified, this will be called. You can stop this by with
options(viewer = NULL)
.
Browser Choice (Mac)
On a Mac, the default browser is called
by /bin/sh/open
which in turn looks at which browser you have set in the system settings. You can
override your default with
browser = "/usr/bin/open -a 'Google Chrome'"
for example.
Browser Choice & Performance
You can check the performance of your browser at peacekeeper.futuremark.com The most relevant score is the rendering category.
Author(s)
Bryan A. Hanson (DePauw University).
See Also
plotSpectra
for non-interactive plotting. Details
about d3.js
are at https://d3js.org. Additional documentation at
https://bryanhanson.github.io/ChemoSpec/
Examples
if (interactive()) {
require("jsonlite")
require("js")
data(metMUD2)
plotSpectraJS(metMUD2)
}