How to Create a Parameterized Data Frame Using R Script Data Frame

For example, Docker Hub provides an API to get hosted docker image info in JSON format. The API URL looks like this.

You can change the last path of the URL to change the target docker image.

You can use a parameter to change the last path on the fly, and you can create a data frame based on the parameterized URL. Here is how.

1. Open a new R Script Data Frame dialog.

Once you open the R Script Data Frame dialog, click “Parameter” button.

2. Create a parameter.

  • Set “Type” for the name
  • Choose “Character” data type
  • Choose “List of Values (Single Select)” for the input type.
  • Define a list of values you want.

Once you are done, click “Save” to save it.

3. Define an R Script Data Frame

Type in an R expression to get the data from the URL in the editor. Use the parameter to construct a URL. Here is an R expression that I used.

    str_c( "", @{Type},  "/")

Once you type in, click “Run” button to preview the data. If it goes well, it fetches the data from the URL and show the result in the preview table. If it looks ok, click the “Save” button.

4. Enjoy!

Now you have a parameterized data frame! You can click the Parameter button on the top right of the window to open the parameter pane.

You can choose a different value to load a different docker image info on the fly.