Need to use 'get':
> ls(9)
[1] "c.Factor" "cls.console"
"date2POSIX"
"Default.par" "delete.NULLs"
[6] "f.apdex" "f.area"
"f.axis"
"f.HHMMSS2hr" "f.hr2HHMMSS"
[11] "f.integrate" "f.queue"
"f.TimeAxis"
"file.size" "function.print"
[16] "generate.stats" "HrsInDay"
"level.plot"
"list.subset" "ls.obj"
[21] "my.axis.POSIXct" "my.func"
"my.ls"
"my.stats" "plot.sar"
[26] "plot.srx.file" "plotReset"
"poly.graph"
"poly.graph.legend" "poly.graph1"
[31] "print.wide" "r.time.cvt"
"read.sar"
"ReadVMstat" "sar.levelplot"
[36] "setParms" "Setwd"
"time2POSIXct"
"unix2EXCEL" "unix2POSIXct"
[41] "x.createColors"> sapply(ls(9), function(x) is.function(get(x)))
c.Factor cls.console date2POSIX
Default.par delete.NULLs
TRUE TRUE TRUE
FALSE TRUE
f.apdex f.area f.axis
f.HHMMSS2hr f.hr2HHMMSS
TRUE TRUE TRUE
TRUE TRUE
f.integrate f.queue f.TimeAxis
file.size function.print
TRUE TRUE TRUE
TRUE TRUE
generate.stats HrsInDay level.plot
list.subset ls.obj
TRUE TRUE TRUE
TRUE TRUE
my.axis.POSIXct my.func my.ls
my.stats plot.sar
TRUE TRUE TRUE
TRUE TRUE
plot.srx.file plotReset poly.graph
poly.graph.legend poly.graph1
TRUE TRUE TRUE
TRUE TRUE
print.wide r.time.cvt read.sar
ReadVMstat sar.levelplot
TRUE TRUE TRUE
TRUE TRUE
setParms Setwd time2POSIXct
unix2EXCEL unix2POSIXct
TRUE TRUE TRUE
TRUE TRUE
x.createColors
TRUE>
On 9/27/07, Tim Bergsma <timb at metrumrg.com>
wrote:> Suppose I want to delete everything in my working directory that is not
> a function. It seems that
>
> sapply(ls(),is.function)
>
> always returns FALSE, because ls() returns objects of mode character.
> How do I evaluate is.function(), not on a character string, but on the
> object that character string represents?
>
> Thanks,
>
> Tim
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?