[R-sig-Geo] Guerry data: making a package

Michael Friendly friendly at yorku.ca
Sat Oct 17 19:23:54 CEST 2009


Hi

Several years ago I sought & received help (thanks!) from people on this 
list regarding map and data
files associated with my article, A.M. Guerry's Moral Statistics of 
France: Challenges for multivariate spatial analysis,
that appeared in Statistical Science, 2007, 22,368-399.  As 
supplementary materials for that article, I prepared
http://www.math.yorku.ca/SCS/Gallery/guerry/

and also included map and data files for R at
http://www.math.yorku.ca/SCS/Gallery/guerry/maps.html#R
but these were really just a sketch that required more work to make them 
fully usable.

Now I'd like to make an R package including the gfrance1 map and the 
guerry data, and other things,
but I found that something in maptools or other packages had changed, so 
that a script that worked
for me with these map files back in Aug, 2008 does so no longer:

 > library(sp)
 > library(maptools)
 > gfrance <- readShapeSpatial("gfrance1")
Error in read.shape(filen = fn, verbose = verbose, repair = repair) :
  File size and implied file size differ, consider trying repair=TRUE

I get the same error with readShapePoly().

Once I can get that sorted out, it's not exactly clear to me exactly how 
to prepare map files
(SpatialPolygonsDataFrame) for a package with appropriate 
documentation.  Using
another version of the Guerry map and data (omitting Corsica) provided 
by Stephane Dray, I *could* read it
successfully, then tried

 > cd("dray")
 > gfrance85 <- readShapePoly("gfrance1")
 > save(gfrance85, file="gfrance85.rda")
 > prompt(gfrance85)
Created file named 'gfrance85.Rd'.
Edit the file and move it to the appropriate directory.

There is no prompt method for SpatialPolygonsDataFrame objects, so 
prompt() just
dumps the entire results of str(gfrance85); I can of course edit out the 
@ polygons list.
Is this the recommended way to include such objects in packages? 

Thanks,
-Michael


-- 
Michael Friendly     Email: friendly AT yorku DOT ca 
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA



More information about the R-sig-Geo mailing list