forked from o2r-project/o2r-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
User guide
tonja26 edited this page Feb 16, 2018
·
16 revisions
- Uploading the Executable Research Compendium (ERC)
- Create an R package in RStudio
- Edit the UI bindings (connect ERC with R package)
- Sign in on the platform
- On the main page, upload a new ERC
Note: To create an ERC, please follow the instructions on the o2r platform website. - Add usual metadata (Required, Optional, Spacetime tabs) and click
SAVE
Figure 1: a) Create a new package in RStudio b) Naming the R package
Note: The RStudio Server instance is running on localhost/rstudio
.
- In the RStudio Server Interface create a new blank package with package name ErcId (Fig. 1)
- Go to the
Files pane
and navigate to the folder namedR
and open the filehello.R
- Copy the contents of the script over to
hello.R
and make sure following requirements are met:- All the code that is required to be used to generate one output MUST be contained in a single function.
- The function MUST return the object which represents the required output.
- In the R script inside the new package, if there are external dependencies, the
library()
function MUST NOT be used. Instead, use the functionrequireNamespace()
. - If there are extra resources or data files required for the script to function it should be uploaded in a directory named
inst
which is to be placed in the root directory of the package.
In order to access these files from the R script in the folderR
, thesystem.file()
function may be used in the following manner:system.file(“data_file_name”, package = “ERC_ID”)
. The argumentpackage
takes the name of the package as the value which in this case is the same as the ERC ID. - Use relative paths within the package to reference other files
- It is a good practice to fill up the file
DESCRIPTION
with metadata related to the R package such as package version, author, description, license etc.
- Define the parameter to manipulate in the function header as well as within the script.
- Note down the name of the function that is used.
- Navigate to the root folder of the package and open the file
NAMESPACE
.- In this file, use the function
import()
to list external packages used on separate lines. - The function defined in the R script has to be exported too. For this, use the function
export()
- In this file, use the function
- Install the R package by clicking on
Install & Reload
(Fig. 2) in theBuild
pane or from theBuild
menu option.
Figure 2: OpenCPU RStudio environment
- In the
UI Bindings
tab you can add a figure that shall allow interaction - Insert following information:
- Figure title
- Figure type (map or time series)
- Function name for creating figure (name of the function of the R package uploaded to rstudio)
- x-axis-label (text that should appear next to the x-axis)
- y-axis-label (text that should appear next to the y-axis)
- x-axis-parameter (column name containing x-values)
-
y-axis-parameter (column name containing y-values) (Fig. 3)
Figure 3: Add figure metadata in UI Bindings
- For a widget (e.g. a slider that allows the user to manipulate the figure) insert following information:
- Default Value (original value used for computation)
- Min Value (minimum value allowed)
- Max Value (maximum value allowed)
- Step size (intervals between min and max value)
- Param Name (parameter name as defined in function header in R package)
- Widget Type (only slider supported so far)
-
Widget description (description that will be shown to the reader) (Fig. 4)
Figure 4: Add metadata to create a widget that will be used to manipulate the figure
- Click
ADD FIGURE TO BINDINGS
- Click
UPDATE
You can add multiple widgets for a single figure.
You can add multiple figures for an ERC.
- On the o2r platform: Go to the paper page of the paper you would like to examine
- On the right part of the screen select the tab
MANIPULATE
(Fig. 5) - Use the slider to set parameter value(s) that shall be used to recompute the visualisation
- Press
RUN WITH NEW PARAMETER(S)
to recompute the visualisation and show the result (this might take some time as the visualisation needs to be computed before it can be shown) - Depending on the figure type you can select different visualisation types for comparison using the corresponding circular buttons on the right
-
Time series
Side-By-Side: The original time series and the changed will be shown in two graphs next to each other
Combined: The original and changed time series will be shown together in one graph -
Maps
Side-By-Side: The original and changed map will be shown next to each other (Fig. 5)
Overlay: The original and changed map will be shown on top of each other. You can use a slider to expand or shorten the map shown at the top so that you are able to compare the maps.
Peephole: The original map is shown completely while the changed map is only partly visible in a rectangular window laid on top of the original map. You move the window over the map using your mouse. The border colour of the map indicates how much difference is between the original and changed map in the movable window. The moving window is resizable.
You can switch between different figures clicking on the corresponding figure tab (underneath the main tab bar containing the MANIPULATE
button).
If you want to download the manipulated figure click DOWNLOAD
. A download of the time series or map images and a text file containing info about the parameters used will be provided.
Figure 5: Manipulate tab providing the comparison user interface