[R-sig-Geo] Error in sample package SP

Rely Al Dianty mareliandaaldianty at gmail.com
Mon Feb 4 12:19:35 CET 2013


Dear R users,


I'm begginer in  R and using Package "SP" for my project to tried sample
make SpatialPolygons object from gridTopology object , I follow the example
of the script but got error.

# Example
 >library(lattice)
 >grd <- GridTopology(cellcentre.offset=c(-175,55), cellsize=c(10,10),
 >cells.dim=c(4,4))
 >SpP_grd <- as.SpatialPolygons.GridTopology(grd)
 >plot(SpP_grd)
 >text(coordinates(SpP_grd), sapply(slot(SpP_grd, "polygons"),
function(i) slot(i, "ID")), cex=0.5)
>trdata <- data.frame(A=rep(c(1,2,3,4), each=4), B=rep(c(1,2,3,4),
each=4), row.names=sapply(slot(SpP_grd, "polygons") *
*SpPDF <- SpatialPolygonsDataFrame(SpP_grd, trdata) *
*>spplot(SpPDF)*


Result error in below

 > trdata <- data.frame(A=rep(c(1,2,3,4), each=4), B=rep(c(1,2,3,4),
each=4), row.names=sapply(slot(SpP_grd, "polygons")
+ SpPDF <- SpatialPolygonsDataFrame(SpP_grd, trdata)
Error: unexpected symbol in:
"trdata <- data.frame(A=rep(c(1,2,3,4), each=4), B=rep(c(1,2,3,4),
each=4), row.names=sapply(slot(SpP_grd, "polygons")
SpPDF"
 > spplot(SpPDF)
Error in spplot(SpPDF) :
   error in evaluating the argument 'obj' in selecting a method for
function 'spplot': Error: object 'SpPDF' not found


Please, any one can help me. Thank u very much


Best Regards,


Rely



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Error-in-sample-package-SP-tp7582471.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list