Publish RScript to Displayr Cloud Drive
Jump to navigation
Jump to search
.
Saves the R Code and Inputs JavaScript of this R Item as an .rscript file in the Displayr Cloud Drive, then accessible via the Company Extensions menu.
const ritem = project.report.selectedItems()[0];
// The file format starts with the R code. The first JavaScript-style comment
// at the beginning of the line ends the R code and signals the beginning of
// the JavaScript code.
const rscript_separator = '// begin js\n'; // we specifically strip this when decoding in RibbonExtensionsMenu._runRScript().
let code = `${ritem.code}\n${rscript_separator}${ritem.codeForGuiControls}`;
let filename = prompt('Displayr Cloud Drive file name:', ritem.name + '.RScript');
filename = filename.trim();
if (filename.length == 0)
filename = 'ritem';
const has_right_extension = /\.RScript/i;
if (!has_right_extension.test(filename))
filename += '.RScript';
Q.saveToDisplayrCloudDrive(code, filename);