[R] How to run own R functions in JRI

jcress410 boywonder410 at gmail.com
Wed Oct 6 19:42:55 CEST 2010

I think the basic answer here is "package it", which I did a couple of times
but found inconvenient if I was going to change the function fairly often,
i've taken a different tact, just including custom functions when R starts,
i wrote a function that runs when I start the R session, loading the
functions in a given directory

Gedit's R plugin handles the Rprofile.conf for me, so thats how I made it
automatically load, you could just edit that file and change the value of
.start{ } 

# jcress, fall 2010
# load all of the scripts in a directory (called path)
# also, define a new function which parses the content in ls()
# so we can clean the session without removing the functions loaded

path <- "~/.Rstartfiles"

for (nm in list.files(path, pattern = "\\.[RrSsQq]$")) {       
source(file.path(path, nm))
cat("loading", nm, "\n")

cleanls <- function(objects){
for (func in list.files("/home/jcress/.Rstartfiles")){
objects[(which(objects == eval(removeext(func))))] <- "" }
objects[which(objects=="cleanls")] <- ""

return(c(objects[which(objects != "")]))

View this message in context: http://r.789695.n4.nabble.com/How-to-run-own-R-functions-in-JRI-tp2965288p2965473.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list