Using David's examples:

do.call(stack, lapply(obs, get))


On Tue, Nov 16, 2010 at 4:04 PM, Kevin Ummel <kevinum...@gmail.com> wrote:

> Sorry, I shouldn't have used 'sum' as an example; I am looking for a
> solution in the case of functions that do not result in simple vectors or
> matrices.
>
> The "real-world" example is something like the following using the 'raster'
> package, though (I think) any command producing an S4 object could be a
> candidate:
>
> r1 <- raster(system.file("external/test.grd", package="raster"))*1
> r2 <- raster(system.file("external/test.grd", package="raster"))*2
>
> obs=objects(pattern=glob2rx("r?"))
>
> #Would like to generate the equivalent of...
>
> stack(r1,r2)
>
> ...using a variation of obs as an argument to 'stack' (potentially very
> long).
>
> Cheers,
> Kevin
>
>
> On Nov 16, 2010, at 5:07 PM, David Winsemius wrote:
>
> >
> > On Nov 16, 2010, at 10:34 AM, Kevin Ummel wrote:
> >
> >> A bit embarrassed to post this seemingly trivial question, but I can't
> find anything in the archive that's quite relevant:
> >>
> >> a1=1
> >> a2=2
> >>
> >> obs=objects(pattern=glob2rx("a?"))
> >>
> >> I want to utilize 'obs' as a function argument to produce something
> like:
> >>
> >> sum(a1,a2)
> >>
> >
> > ?get
> > > sum(sapply(obs, get))
> > [1] 3
> >
> >
> >> Obviously, sum(obs) doesn't work, but I've tried variations of 'eval',
> 'parse', 'mget', and 'noquote' without success. What am I missing?
> >>
> >> Thanks,
> >> Kevin
> >>
> > --
> > David Winsemius, MD
> > West Hartford, CT
> >
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
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