Create App From Function and Inputs

appify(f, inps, out = "plot", id = NULL)

Arguments

f

a function as a string

inps

a list of inputs, see ?inp_text, ?inp_number and ?inp_dropdown

out

the output type (currently the only valid value is "plot")

id

html identifier, when NULL the id will be generated randomly. If you set the id manually, make sure it is unique.

Value

html

Examples

# Assume the function my_function has arguments x, y: # my_function <- function(x, y) { # # Code # } appify(f = "my_function", inps = list(x = inp_number(), y = inp_number()))
#> <div> #> <form id="form-SwlKLUUEdLieexombQQeuRHfdVHIyvQg" class="well"> #> <fieldset class="row"> #> <div class="col-sm-4"> #> <label>x</label> #> <input id="x-SwlKLUUEdLieexombQQeuRHfdVHIyvQg" class="form-control" type="number" min="0" max="100"/> #> </div> #> <div class="col-sm-4"> #> <label>y</label> #> <input id="y-SwlKLUUEdLieexombQQeuRHfdVHIyvQg" class="form-control" type="number" min="0" max="100"/> #> </div> #> </fieldset> #> <button id="submit-SwlKLUUEdLieexombQQeuRHfdVHIyvQg" class="btn btn-primary" type="button">Submit</button> #> </form> #> <div style="height: 600px;" class="well" id="target-SwlKLUUEdLieexombQQeuRHfdVHIyvQg"></div> #> <script type = "text/javascript">$("#submit-SwlKLUUEdLieexombQQeuRHfdVHIyvQg").click(function(){ #> var req = $("#target-SwlKLUUEdLieexombQQeuRHfdVHIyvQg").rplot( #> "my_function", #> {x : (function(){ #> var x = $('#x-SwlKLUUEdLieexombQQeuRHfdVHIyvQg').val(); #> return(isNaN() ? x : parseFloat(x)); #> })() , #> y : (function(){ #> var x = $('#y-SwlKLUUEdLieexombQQeuRHfdVHIyvQg').val(); #> return(isNaN() ? x : parseFloat(x)); #> })() } #> ); #> req.fail(function(){ #> alert("Error: " + req.responseText); #> }); #> }); </script> #> </div>