On Mon, Oct 4, 2010 at 8:27 PM, Hans Ekbrand <h...@sociologi.cjb.net> wrote:
> On Mon, Oct 04, 2010 at 10:07:06AM -0400, Gabor Grothendieck wrote:
>> Some small tweaks.   If you use simplify=FALSE then it will guarantee
>> that a list is returned:
>>
>>    sapply(my.names, get, simplify = FALSE)
>>
>> for example, compare the outputs of:
>>
>>    sapply(c("letters", "LETTERS"), get)
>>    sapply(c("letters", "LETTERS"), get, simplify = FALSE)
>
> Thanks Gabor,
>
> But get() fails to find my objects, though get() successfully finds
> "letters" and "LETTERS" (but they are part of the global environment,
> I assume).

Specify the environment from which you want get to fetch them,  See ?get
For example, below we tell it to look in the current environment:

my.test.function <-  function() {
  a <- 1:3
  b <- c("x", "y")
  sapply(c("a", "b"), get, environment(), simplify = FALSE)
}
my.test.function()


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
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