2. Create a user interface in the App Builder
Use the App Builder to map the input arguments in the code for example, main.R, to user inputs in the App Panel.
Click on the App Builder tab on the left to enter the App Builder.
The App Builder contains four separate sections. In this guide, we will continue use the sample file to fill in each of the sections.
General - covers basic information about the App
Data - enables the attaching of data assets that can be swapped out
Parameters - set configurable parameters that are sent as arguments to run the script
Display Result After Run - choose output files to display in the main window
Adding General Information
This section allows you to set the title for the application along with a short description of the App usage. It is recommended to create aREADME.md
file along with the application to help users understand the functionality of the tool, the inputs and outputs of the application, and any additional necessary information.
The example below shows the completion of the General section. This capsule plots a sine function.
This description will not appear outside of build mode until data or parameters have been added to the capsule.
Adding Data
Data consists of any data assets that can be attached to the capsule.
In the example, the input data is the user's own data being attached as a data asset. Let's create the Data Asset and attach it to the capsule.
To create an asset containing the data:
Click Files
Download
sample-data.txt
Click Manage Data Assets
Create a new data asset from the downloaded file
This is a quick walkthrough on creating Data Assets via uploading a file. Please check out this guide for more details.
Now the Data Asset is created, get back to the App Builder and continue adding the Data Assets.
Navigate to App Builder
Enter Build Mode - click Create App
Click Attach Data Assets
Select the data asset
Click Add
Provide the information for the:
Label
Default Data
Description
Click Save
Adding Parameters
App Panel supports three types of input parameters. The icons at the top of the Parameters panel represent each type:
main.R
plots a sine function. You will set up the following three arguments in this example from main.R
.
plot_title
: the title of the figure in the result file.number_of_cycles
: # of cycles for the sine function.input_data
: a txt file that indicates the sampling rate.
The argumentsargs[x]
in line 9-11 need to match with the three input parameters in the panel in sequential order from top to bottom. The following three tabs show you how to set the input parameters up respectively.
The following three tabs show you how to set up three parameters in the Parameters panel. Click on each tab for more details.The first parameter value you set up goes toargs[1]
in the code. It is stored in plot_title
as the first argument. This parameter lets the viewer type the plot title by entering any text. A Text Parameter is the most appropriate parameter type here.
| |
The result of the saved text parameter. |
Swapping the Order of App Panel Parameters
Display Result after Run
This allows you to set results to display to the user after running the capsule. These are static paths, so the outputs will need to have the same name for every run. In this example, fig1.png
and fig2.png
are always output, they can be set as the results display.
Note: a reproducible run must be done in order to see available results files to display after the run.
After adding both results:
The final App Panel result is displayed below:
Last updated