Skip to content

I need to get function name from R file

3 messages · Eik Vettorazzi, purushothaman

#
Hi,

i need to get functions name from R file

example

test.R file having 2 functions like

add<-function()
{
a+b
}
sub<-function()
{
a-b
}

how to get function name from test.R file

i need output is functions are add,sub.

Thanks
B.Purushothaman

--
View this message in context: http://r.789695.n4.nabble.com/I-need-to-get-function-name-from-R-file-tp4636136.html
Sent from the R help mailing list archive at Nabble.com.
#
Hi,
how about this:

sandbox<-new.env()
sys.source("test.R",envir=sandbox)

#all objects defined in "test.r"
(tstf<-ls(env=sandbox))

#just the functions
tstf[sapply(tstf, function(n) exists(n, envir = sandbox, mode =
"function", inherits = FALSE))]

hth

Eik

Am 11.07.2012 15:22, schrieb purushothaman: