[R-sig-Geo] change in sp::Lines() breaks example in my package

Michael Friendly friendly at yorku.ca
Tue Jul 27 16:22:14 CEST 2010


[Running R.2.11.1, Win XP]

I just updated sp from sp_0.9-65 to sp_0.9-66 after receiving a report 
from the CRAN team that my HistData
package now generates errors in at least one documentation example.  It 
occurs in example(Snow), which
worked successfully under the previous versions of sp.  I don't 
understand the nature of the error, or how to
correct it.  Can someone point me in a useful direction?

Here is the complete portion of the example (to draw Snow's cholera map 
of London), suitable for cut/paste to R:

#install.packages("HistData")    # if necessary
library(HistData)
library(sp)

# streets
slist <- split(Snow.streets[,c("x","y")],as.factor(Snow.streets[,"street"]))
Ll1 <- lapply(slist,Line)
Lsl1 <- Lines(Ll1,paste("Street",1:length(Ll1)))
Snow.streets.sp <- SpatialLines(list(Lsl1))
plot(Snow.streets.sp, col="gray")
title(main="Snow's Cholera Map of London")

# deaths
Snow.deaths.sp = SpatialPoints(Snow.deaths[,c("x","y")])
plot(Snow.deaths.sp, add=TRUE, col ='red', pch=15, cex=0.6)

# pumps
spp <- SpatialPoints(Snow.pumps[,c("x","y")])
Snow.pumps.sp <- SpatialPointsDataFrame(spp,Snow.pumps[,c("x","y")])
plot(Snow.pumps.sp, add=TRUE, col='blue', pch=17, cex=1.5)
text(Snow.pumps[,c("x","y")], labels=Snow.pumps$label, pos=1, cex=0.8)

Here is the transcript showing the error with Lines:

 > # streets
 > slist <- 
split(Snow.streets[,c("x","y")],as.factor(Snow.streets[,"street"]))
 > Ll1 <- lapply(slist,Line)
 > Lsl1 <- Lines(Ll1,paste("Street",1:length(Ll1)))
Error in Lines(Ll1, paste("Street", 1:length(Ll1))) : Single ID required
 > Snow.streets.sp <- SpatialLines(list(Lsl1))
Error in is.vector(X) : object 'Lsl1' not found

Some tests:
 > length(Ll1)
[1] 528
 > length(unique(paste("Street",1:length(Ll1))))
[1] 528
 >


Below is my sessionInfo():

 > sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252  
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                         
[5] LC_TIME=English_United States.1252   

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
[1] sp_0.9-66         KernSmooth_2.23-3 HistData_0.6-8  

loaded via a namespace (and not attached):
[1] grid_2.11.1    lattice_0.18-8 tools_2.11.1 
 >

-- 
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    Web:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA



More information about the R-sig-Geo mailing list