[R] data format for ppinit
Roger Bivand
Roger.Bivand at nhh.no
Mon Sep 10 09:18:48 CEST 2001
On Mon, 10 Sep 2001, Susumu [ISO-2022-JP] Tanimura/$BC+B<(B $B?8(B wrote:
> After installation of R into VineLinux2.1.5, I started to enjoy statistics
> following some instruction, and found it very useful.
>
> One of my main purpose to use R is to try spatial statistics. Since
> library named "spatial" has already installed, I just tried ...
> > library(spatial)
> > towns <- ppinit(test.dat)
help(ppinit)
gives the documentation for ppinit. If you look at:
example(ppinit)
and examine the file it reads ($R_HOME/library/spatial/data/towns.dat),
you will see that the format described on the help page is easy to
follow:
69
TOWNS
0 40 0 40 1
.84 39.16
.84 33.20
4.24 34.04
....
69 points
a header
xl xu yl yu scale (the point (xl, yl) is the lower left corner of the
region of interest, (xu, yu) the upper right corner; scale is usually 1)
followed by coordinate pairs for the specified number of points.
> ------- test.dat -------
> x,y
> 4,7
> 5,7
> 5,8
> 5,9
> 6,7
> 6,8
> 6,9
> 7,8
>
> --------------------------
This is a different problem. You are assuming that you can use commas to
separate values - in general values should be separated by white
space. For ppinit, your file would need to be:
8
TEST
3 8 6 10 1
4 7
5 7
5 8
5 9
6 7
6 8
6 9
7 8
> pptest <- ppinit("/tmp/test.dat")
> str(pptest)
List of 3
$ x : num [1:8] 4 5 5 5 6 6 6 7
$ y : num [1:8] 7 7 8 9 7 8 9 8
$ area: Named num [1:4] 3 8 6 10
..- attr(*, "names")= chr [1:4] "xl" "xu" "yl" "yu"
> plot(pptest)
now works fine. Please also refer to the section of Venables & Ripley
(Modern Applied Statistics with S-Plus) about the functions provided in
the spatial package.
Roger
--
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
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list