appify.Rd
Create App From Function and Inputs
appify(f, inps, out = "plot", id = NULL)
f | a function as a string |
---|---|
inps | a list of inputs, see |
out | the output type (currently the only valid value is |
id | html identifier, when |
html
# 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>