deployrInput | R Documentation |
The deployrInput
function allows you to declare the required inputs for your R script and provide default values for these inputs. Default values ensure that your script can run successfully and that your R code is portable across your local environment and in the DeployR server environment.
The inputs can be used to:
Test a script locally within your R IDE environment AND again remotely within the DeployR Repository Manager Test page. In both test cases, use the default values to verify consistent behavior across environments.
Provide client application developers with clear guidance as to which script inputs their application will be required to supply to produce meaningful output.
For more information on declaring your inputs, see the ‘Writing Portable R Code’ document for your DeployR version on the official DeployR website (http://go.microsoft.com/fwlink/?LinkId=708337).
deployrInput(content)
content |
A valid JSON string configuration using the following structure:
|
The name
, render
, and default
arguments are required. The entire input to the deployrInput
function must be a valid JSON string. Within that string, JSON dictates that the argument names be double-quoted as should any strings.
Examples:
deployrInput('{"name": "myName", "render": "integer", "default": 5}')
deployrInput("{\"name\": \"myName\", \"render\": \"integer\", \"default\": 5}")
deployrInput('{"name": "myName", "render": "logical", "default": "true"}')
Important! In order to display an input configuration in the Test page of the DeployR Repository Manager, the argument for the deployrInput
function must be a single literal string, and cannot be another function or variable. For example, the following code could be used in an R script; however, no controls would appear in the Script Inputs pane in the Test page.
args <- '{"name": "myName", "render": "integer", "default": 5}'
deployrInput(args)
## Not run:
# Creates an integer variable named age if it does not exist
deployrInput('{ "name": "age", "label": "Age", "render": "integer", "default": 6 } ')
# Creates a number variable named amt if it does not exist
deployrInput('{ "name": "amt", "label": "Amount", "render": "numeric",
"default": 6, "min": 5, "max": 10 } ')
# Creates a number variable named amt if it does not exist
deployrInput('{ "name": "amt", "label": "Amount", "render": "numeric", "default": 6 } ')
# Creates a logical variable named ownHome if it does not exist
deployrInput('{ "name": "ownHome", "label": "Homeowner", "render": "logical",
"default": "TRUE" } ')
# Creates a character variable named fname if it does not exist
deployrInput('{ "name": "fname", "label": "First Name", "render": "character",
"default": "Sue" } ')
# Creates a character variable named filetype if it does not exist
deployrInput( '{ "name": "filetype", "label": "File Type", "render": "character",
"default": "png", "labels": [ "png", "bmp", "jpg", "tiff" ] } ')
# Creates a factor variable named filetype if it does not exist
deployrInput( '{ "name": "filetype", "label": "File Type", "render": "factor",
"default": "png" } ')
# Creates an ordered factor variable named rating if it does not exist
deployrInput('{ "name": "rating", "label": "Rating", "render": "ordered",
"levels": [ "Good", "Better", "Best" ], "default": "Good" } ')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.