# ---------------------------------------------------------------------- # LANGUAGE: R Language API # ====================================================================== # AUTHOR: Michael McLennan, Purdue University # Copyright (c) 2004-2012 HUBzero Foundation, LLC # # See the file "license.terms" for information on usage and # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. # ====================================================================== language "R Language" { extension ".R" command {R --slave --no-save --no-restore --silent --args @driver < @tool/@@FILENAME@@} main {# ---------------------------------------------------------------------- # MAIN PROGRAM - generated by the Rappture Builder # ---------------------------------------------------------------------- require(Rappture) # open the XML file containing the run parameters args <- commandArgs() # command line: R --slave --no-save --no-restore --silent --args @driver # ^1 ^2 ^3 ^4 ^5 ^6 ^7 io <- rp_lib(args[7]) ######################################################### # Get input values from Rappture ######################################################### @@INPUTS@@ ######################################################### # Add your code here for the main body of your program ######################################################### ######################################################### # Save output values back to Rappture ######################################################### @@OUTPUTS@@ rp_lib_result(io) quit("no",0) } input boolean { code "\n# get input value for $path" code "# returns value as string \"yes\" or \"no\"" code "$id <- rp_lib_get_string(io,\"$path.current\") == \"yes\"" } input image { code "\n# get input value for $path" code "# returns base64-encoded image data" code "imdata <- rp_lib_get_string(io, \"$path.current\")" } input number { set units [attr get units] if {$units ne ""} { code "\n# get input value for $path and convert to $units" code "str <- rp_lib_get_string(io, \"$path.current\")" code "$id <- rp_units_convert_double(str,\"$units\")" } else { code "\n# get input value for $path" code "$id <- rp_lib_get_string(io, \"$path.current\")" } } input * { code "\n# get input value for $path" code "$id <- rp_lib_get_string(io, \"$path.current\")" } output curve { code "\n# save output value for $path" code "# assumes output in vectors x and y" code "str <- paste(sprintf(\"%g %g\\n\",x,y), collapse=\"\")" code "rp_lib_put_string(io,\"$path.component.xy\",str,FALSE)" } output histogram { code "\n# save output value for $path" code "# assumes output in vectors x and y" code "str <- paste(sprintf(\"%g %g\\n\",x,y), collapse=\"\")" code "rp_lib_put_string(io,\"$path.component.xy\",str,FALSE)" } output * { code "\n# save output value for $path" code "rp_lib_put_string(io,\"$path.current\",$id,FALSE)" } }