[R-sig-Geo] spRbind() limited to 2 objects?
Roger Bivand
Roger.Bivand at nhh.no
Sun Nov 4 18:27:08 CET 2007
On Sun, 4 Nov 2007, Agustin Lobo wrote:
> Is spRbind() limited to 2 objects? It seems so but this
> detail is not mentioned in the doc. Note:
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
>
>> class(pols.ferns1)
> [1] "SpatialPolygonsDataFrame"
> attr(,"package")
> [1] "sp"
>> class(pols.ferns2)
> [1] "SpatialPolygonsDataFrame"
> attr(,"package")
> [1] "sp"
>> class(pols.ferns3)
> [1] "SpatialPolygonsDataFrame"
> attr(,"package")
> [1] "sp"
>> class(spRbind(pols.ferns2,pols.ferns3))
> [1] "SpatialPolygonsDataFrame"
> attr(,"package")
> [1] "sp"
>> class(spRbind(pols.ferns1,pols.ferns3))
> [1] "SpatialPolygonsDataFrame"
> attr(,"package")
> [1] "sp"
>> class(spRbind(pols.ferns1,pols.ferns2,pols.ferns3))
> Error in spRbind(pols.ferns1, pols.ferns2, pols.ferns3) :
> unused argument(s) (<S4 object of class "SpatialPolygonsDataFrame">)
>> class(spRbind(spRbind(pols.ferns1,pols.ferns2),pols.ferns3))
> [1] "SpatialPolygonsDataFrame"
> attr(,"package")
> [1] "sp"
>
> Thanks!
>
> Agus
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list