User Tools

Site Tools


How to use JUICE-R function

JUICE-R function is a way how to run R script directly from JUICE, using data exported from JUICE as an input of R. You need to have both JUICE and R installed on your computer, and JUICE needs to know the directory of R program.

Downloading the JUICE-R script into your computer

You need to get the JUICE-R script and save it to your computer. You may create, e.g. subfolder JUICE-R in the JUICE folder (usually in C:\Program files\JUICE), where you will store all JUICE-R scripts at one place 1). The JUICE-R scripts may be downloaded in Available R scripts link in this website, or in other sources on the internet (if available). They have *.r extension and structure specified in How to write the R script for JUICE link. If you know how to write R scripts, you may write JUICE-R function by yourself.

Launching JUICE-R script from JUICE

If you have the JUICE-R script saved in your computer, open JUICE, and in JUICE menu, go to Analysis > JUICE-R functions, or simply use CTRL+W shortcut. The JUICE-R wizard will open (see Fig. 1 below).

Click on Append R-script and select the *.r file with JUICE-R script in your computer.

If the JUICE-R script contains a header with JUICE-R tags, some of the choices are done automatically, and they will be disabled - in that case, you just click Run. Otherwise, the following choices are available:

  • Data transformation - choose how to transform species data
  • Export - which data to export
  • Relevé used in analysis - select the colour (or all) relevés
  • Type of R environment - do you want to open R GUI (Rgui.exe) or run the script as a batch file (R.exe)?
    • Rgui.exe will open graphical interface to R and copy (via clipboard) the script loading the data from the folder into the command line. Note: avoid opening other programs at the moment when you run the JUICE-R script in JUICE - the script for loading the data will be copied to the active window at the moment of export from JUICE2).
    • R.exe will send the data and script in a batch mode into R, process it and return the result, without opening R graphical user interface (GUI). R data files can be found in the folder of currently associated R program (e.g. C:\Program Files\R\R-x.x.x\bin\, where x.x.x is the version of your R associated with JUICE via Files > Options > External program paths).
  • Editor - you can edit the script directly (however, these edits won't be saved into the original file and will be valid only temporarily for current run of R)
  • Script file name - you can append the R script from selected folder (Append R script) or cancel it (Clear). If the script comes with pdf help file (its name has to be the same as is the name of the script and it has to be in the same folder), then clicking on PDF description button will open this pdf.
  • If you don't want to export all header data, you may choose only some in the column at the right.
  • If the PDF or WWW description button is available, it means that the JUICE-R scripts come with the help file (either as a pdf file or a website) with instructions how to use it.

In the end, press 'Run' button and the R script will launch.

Figure 1. JUICE-R wizard to run JUICE-R code in R from JUICE.
The folder could be in any folder in your computer which is accessible to you - if you do not have administrator rights and cannot access Program Files folder, create it, e.g. in your Documents.
This means that if you click on Run button in JUICE, JUICE will export the data into the working folder, automatically open R GUI interface and copy (via clipboard) the R code for loading the data and script into R command line. If you interfere in some way with opening R GUI interface (e.g. by opening Excel), it may happen that the R script will be copied elsewhere (e.g. into the Excel), not into R.
how_to_use_juice-r.txt · Last modified: 2018/01/06 11:04 by david