[R-sig-Geo] Stacking objects of other class

Bart bart at njn.nl
Fri Jun 15 16:44:07 CEST 2012


Dear list,

Currently I'm developing an r package for movement analysis, it is quite 
heavily based on the raster and sp package. One of the things we want to 
do is combine multiple objects into one combined object, much like stack 
stacks multiple rasters. We thought of using the in raster defined 
generic stack function for ease of use but this poses a problem.

First calling it with a list is not possible since that method is 
already set in the raster package, then i thought about the following way.

setMethod("stack", signature(x='ourClass'), ....

and than call it as following

do.call('stack', list_of_objects_of_our_class)

I think this works in principle fine the problem is that there needs to 
be an argument called x to the call to stack, while our list does not 
necessarily contain this. One way around is removing the names from the 
list but i would like to avoid that also to keep indexing simple.

Is there any other way that we could use the stack function without 
renaming our list?

I hope the problem is a bit clear, thanks in advance

Bart



More information about the R-sig-Geo mailing list