On Tue, 18 May 2010, Agustin Lobo wrote:


Thanks. I have to do it this way as the tables are inconsistent:

besosbound...@data <- data.frame(Basin="Besos")
terbound...@data <- data.frame(Basin="Ter")
BesosBoundary <- spChFIDs(BesosBoundary, "Besos")
TerBoundary <- spChFIDs(TerBoundary, "Ter")
delme <- rbind.SpatialPolygonsDataFrame(BesosBoundary,TerBoundary)

Nevertheless, as I have several of these shape files, I'm trying a loop.
But while the following works:
i <- 1
basnom <- unlist(strsplit(bas[i], "Boundary"))
basnom
[1] "Besos"

slot(BesosBoundary,"data") <- data.frame(Basin = basnom)

the following (which I need for using the names in an array) does not:
bas[i]
[1] "BesosBoundary"

slot(get(bas[i]),"data") <- data.frame(Basin = basnom)
Error in slot(get(bas[i]), "data") <- data.frame(Basin = basnom) :
 could not find function "get<-"

am I doing something wrong or have I hitted an inconsistency?

The error message seems explicit. Use get() first to a temporary local object, do slot()<- on that object, and assign() back to bas[i]. Untried.

Roger


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.biv...@nhh.no

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to