A few years back, I wrote some code to plot maps with the maptools package. Now I am trying to reproduce my results, only to find out that maptools has been updated and my code no longer works. I've been able to fix the first part of it by forcing spb <- maptools:::read.shape("/home/sasha/Documents/maps/spb.shp") (as read.shape has been deprecated) but now when I do plot(spb, xlab="Longitude", ylab="Latitude", main="Map of St Petersburg, Russia") I get the message Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y' What's the new syntax that I'm supposed to use? I'm using R version 2.12.0 (2010-10-15) on x86_64-pc-linux-gnu (64-bit) Thanks, ------------------------ Aleksandr Andreev Graduate Student - Department of Economics University of North Carolina at Chapel Hill Mobile: +1 303 507 93 88 Skype: typiconman
I know the default plot() method expects dat$x and dat$y to exist and be equal if you simply try> plot(dat)Try looking at> methods(plot)to see if there is a specified method from maptools, then check documentation on ?plot.methodfrommaptools Otherwise, check spb for $x and $y objects. -------------------------------------- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 "Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the word... imbue it." - Jubal Early, Firefly From: Aleksandr Andreev <aleksandr.andreev at gmail.com> To: r-help at r-project.org Date: 11/10/2010 01:10 PM Subject: [R] maptools package Sent by: r-help-bounces at r-project.org A few years back, I wrote some code to plot maps with the maptools package. Now I am trying to reproduce my results, only to find out that maptools has been updated and my code no longer works. I've been able to fix the first part of it by forcing spb <- maptools:::read.shape("/home/sasha/Documents/maps/spb.shp") (as read.shape has been deprecated) but now when I do plot(spb, xlab="Longitude", ylab="Latitude", main="Map of St Petersburg, Russia") I get the message Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y' What's the new syntax that I'm supposed to use? I'm using R version 2.12.0 (2010-10-15) on x86_64-pc-linux-gnu (64-bit) Thanks, ------------------------ Aleksandr Andreev Graduate Student - Department of Economics University of North Carolina at Chapel Hill Mobile: +1 303 507 93 88 Skype: typiconman ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Aleksandr - What happens when you use library(maptools) spb = readShapePoly('/home/sasha/Documents/maps/spb.shp') - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spector at stat.berkeley.edu On Wed, 10 Nov 2010, Aleksandr Andreev wrote:> A few years back, I wrote some code to plot maps with the maptools > package. Now I am trying to reproduce my results, only to find out > that maptools has been updated and my code no longer works. > > I've been able to fix the first part of it by forcing > spb <- maptools:::read.shape("/home/sasha/Documents/maps/spb.shp") > > (as read.shape has been deprecated) > > but now when I do > plot(spb, xlab="Longitude", ylab="Latitude", main="Map of St > Petersburg, Russia") > > I get the message > Error in xy.coords(x, y, xlabel, ylabel, log) : > 'x' is a list, but does not have components 'x' and 'y' > > What's the new syntax that I'm supposed to use? > > I'm using R version 2.12.0 (2010-10-15) on x86_64-pc-linux-gnu (64-bit) > > Thanks, > > ------------------------ > Aleksandr Andreev > Graduate Student - Department of Economics > University of North Carolina at Chapel Hill > Mobile: +1 303 507 93 88 > Skype: typiconman > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >