Data set 'c2' not found

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Data set 'c2' not found

Sam R. Smith
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20040915/9d6d719c/attachment.pl>

Reply | Threaded
Open this post in threaded view
|

Data set 'c2' not found

Roger Bivand
Administrator
On Wed, 15 Sep 2004, sam smith wrote:

> Hi, there,
> I put a shapefile c2 under rw1091\library\maptools\shapes and run the following sample codes and it works well to produce a map. However, when I tried to use data(c2),
> it reports: Warning message: Data set 'c2' not found in: data(c2)
> How can I solve it?
> (Actually c2 is a copy of columbus data).
> > try2 <- read.shape(system.file("shapes/c2.shp", package="maptools")[1])
> Shapefile Type: Polygon   # of Shapes: 49
> > mappolys <- Map2poly(try2, as.character(try2$att.data$NEIGNO), raw=FALSE)
> > data(c2)
> Warning message:
> Data set 'c2' not found in: data(c2)

While it may be tempting to assume otherwise, data() only loads specified
data sets belonging to packages, and is only used for providing examples
with data objects. So do not use it for your own data. The contents of the
DBF file are in the $att.data element of the map object, in your case
c2$att.data. The help page for read.shape() says:

att.data: a data frame of data from the associated DBF file; note that
          the field names are adjusted to use in R using
          'make.names()', and so will permit the underscore character
          from R release 1.9.0.

So use them from there, or if you like, assign the element to a new data
frame:

c2data <- c2$att.data

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no



Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway