Skip to content

spRbind() limited to 2 objects?

2 messages · Agustin Lobo, Roger Bivand

#
Is spRbind() limited to 2 objects? It seems so but this
detail is not mentioned in the doc. Note:
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
Error in spRbind(pols.ferns1, pols.ferns2, pols.ferns3) :
   unused argument(s) (<S4 object of class "SpatialPolygonsDataFrame">)
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"

Thanks!

Agus
#
On Sun, 4 Nov 2007, Agustin Lobo wrote:

            
Well, the signatures are for two objects of the same class only, so the 
most direct reading is that the spRbind methods in maptools take two and 
only two objects.

The rbind and cbind functions in R base are not methods, and do not do 
method dispatch.

There are also rbind.*  methods in sp which do essentially the same thing, 
can take multiple objects, but only dispatch on the class of the first 
object, so error terminate if one of the remaining objects is not of the 
same class.

The spRbind methods were thought of as being able to accumulate within a 
loop, or by multiple applications as you show.

Roger