[R] How to run own R functions in JRI
jcress410
justin.cress at uky.edu
Thu Oct 7 18:30:41 CEST 2010
I guess the best answer to your question depends on the specifics of the
implementation, but, i think if I were in your situation and I wanted to be
able to call a function "foo" found in file "foo.R" every time a user
clicked a button, i'd just
source("path to "foo.R")
which just parses the contents of the file as if they were included in the
script. So, foo.R could be sourced from any of your other scripts.
Just make sure to rm(list = loaded files) so that you dont try to read the
same function twice, or you could wrap your source() call in something like
if (!grepl(FOO,ls())) { source(path too "foo.R") }
which will only load if the function isn't already loaded.
I guess that could be cause problems if you don't know absolute directory
structure, but ?source() may help you figure out if you can use relative
paths..
if not, off the top of my head you might be able to discover the path using
file.path()
I guess if your program installs files to directories in some predictable
way, this won't be a problem.
--
View this message in context: http://r.789695.n4.nabble.com/How-to-run-own-R-functions-in-JRI-tp2965288p2967140.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list