One-to-many table relationship to shapefile polygon in spplot / plot - possible?
On Wed, 6 Jan 2010, Noli Sicad wrote:
Review ?reshape to convert to wide format before trying to merge into your object for using spplot(). Roger
OK. The answer is not possible. I have been studying reshape - cast and melt. The illustration submit in my earlier post, can be easily done. But here is the real data (below) is bit harder.
If you start with reshape in the stats package, not the reshape package, it may be easier. Using reshape is always hard, but the wide format is what you need. There is no provision for one-to-many for spatial features.
I have more problem deleting shapefile polygons that doesn't have data in dbf. I am just learning to use R in the last weeks. I have to find some example script how to do polygon delete. I am reading sp package. Searching in the archives of various list.
You delete spatial features from a Spatial* or Spatial*DataFrame object in the usual way with the "[" operator. Just treat them as data.frame objects as a first approximation. Roger
Thanks, Noli
~~~~~~~~~
Input data
C_ID CROP Period Age
83 SORI 1 31
84 SORI 1 32
85 SORI 1 33
86 SORI 1 34
82 SORI 2 28
83 SORI 2 29
84 SORI 2 30
93 SORM 2 35
62 OTRM 3 30
82 SORI 3 27
3 SORM 3 35
82 SORI 4 26
4 SORM 4 34
5 OTRI 5 25
5 OTRM 5 29
5 SORM 5 32
5 SORM 5 33
5 SORM 5 35
6 OTRI 6 22
6 OTRI 6 23
6 OTRI 6 24
6 OTRM 6 26
6 OTRM 6 27
6 OTRM 6 28
7 OTRM 7 26
8 OTRM 8 26
9 OTRM 9 26
10 OTRM 10 24
10 OTRM 10 25
10 OTRM 10 26
10 SORM 10 31
Desired table
C_ID CROP P 1 P 2 P 3 P 4 P 5 P 6 P 7
P 8 P 9 P 10
- Hide quoted text -
83 SORI 31
84 SORI 32
85 SORI 33
86 SORI 34
82 SORI 28
83 SORI 29
84 SORI 30
93 SORM 35
62 OTRM 30
82 SORI 27
3 SORM 35
82 SORI 26
4 SORM 34
5 OTRI 25
5 OTRM 29
5 SORM 32
5 SORM 33
5 SORM 35
6 OTRI 22
6 OTRI 23
6 OTRI 24
6 OTRM 26
6 OTRM 27
6 OTRM 28
7 OTRM 26
8 OTRM 26
9 OTRM
26
10 OTRM
24
10 OTRM
25
10 OTRM
26
10 SORM
31
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no