On 28/09/2007, at 6:52 AM, Tim Bergsma 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?

sapply(ls(),function(x){is.function(get(x))})

One must distinguish between an object and its name.

(See ``Alice Through the Looking-Glass'' by Lewis Carroll aka Rev.  
Charles L. Dodgson. :-) )

                        cheers,

                                Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confidenti...{{dropped}}

______________________________________________
R-help@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.

Reply via email to