colorkey print order is incorrect??
Jim, your percentage variable is read as a factor; just check: > class(tx3_sp$CK_PCT) this is because R does not understand % symbols (unless you tell it). Convert it to numeric by > tx3_sp$CK_PCTN = as.numeric(unlist(strsplit(tx3_sp$CK_PCT,"%"))) and use spplot on the new variable. The as.table=TRUE argument does not have an effect when plotting a single variable only. Thanks; the list is aware of the NY Times article: https://stat.ethz.ch/pipermail/r-sig-geo/2009-January/004789.html -- Edzer
Jim Burke wrote:
Question. When I use the code below to print a list of values to the right of my graph, the colorkey list appears unusual. At the top the list of percentages tops out at 90.87% instead of the expected 100%. The 100% appears at the bottom below the lowest percent 14.29%. The numbers of tx3_sp CK_PCT are read in as follows. ID is the PCT and CK_PCT is what's plotted.
tx3_sp
An object of class ?SpatialPolygonsDataFrame?
Slot "data":
PCT CD COMM JP LD SB SS CK_TOT CK_PCT TOT_VOTE
1 1120 CD-03 COMM01 JP-3 LD-102 SB-12 SS-16 1693 90.87% 1863
2 1121 CD-05 COMM01 JP-3 LD-102 SB-12 SS-16 634 54.28% 1168
3 1124 CD-05 COMM01 JP-3 LD-102 SB-12 SS-16 584 43.39% 1346
4 1135 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 815 33.51% 2432
5 1136 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 446 52.84% 844
6 1719 CD-03 COMM01 JP-3 LD-102 SB-12 SS-16 1392 68.17% 2042
7 1720 CD-03 COMM01 JP-3 LD-102 SB-12 SS-16 523 66.20% 790
8 1723 CD-03 COMM01 JP-3 LD-102 SB-12 SS-16 788 82.34% 957
9 1724 CD-03 COMM01 JP-3 LD-102 SB-12 SS-16 994 69.41% 1432
10 1725 CD-32 COMM01 JP-3 LD-102 SB-12 SS-16 31 59.62% 52
11 1802 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 999 44.20% 2260
12 1803 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 672 44.24% 1519
13 1804 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 280 39.94% 701
14 1805 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 654 48.12% 1359
15 1806 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 495 37.61% 1316
16 1807 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 695 40.81% 1703
17 1809 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 563 47.11% 1195
18 1810 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 461 42.92% 1074
19 1811 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 779 42.61% 1828
20 1812 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 585 37.77% 1549
21 1816 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 311 32.16% 967
22 1817 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 528 44.18% 1195
23 1819 CD-32 COMM01 JP-3 LD-102 SB-12 SS-08 338 47.88% 706
24 1820 CD-32 COMM01 JP-3 LD-102 SB-12 SS-16 305 70.11% 435
25 1821 CD-03 COMM01 JP-3 LD-102 SB-12 SS-16 617 74.07% 833
26 2115 CD-03 COMM02 JP-2 LD-102 SB-12 SS-16 1 14.29% 7
27 2121 CD-03 COMM02 JP-2 LD-102 SB-12 SS-16 646 50.91% 1269
28 2122 CD-03 COMM02 JP-2 LD-102 SB-12 SS-16 120 60.00% 200
29 2126 CD-03 COMM02 JP-2 LD-102 SB-12 SS-16 511 57.55% 888
30 2127 CD-03 COMM02 JP-2 LD-102 SB-12 SS-16 522 41.04% 1272
31 2128 CD-03 COMM02 JP-2 LD-102 SB-12 SS-16 390 49.49% 788
32 2129 CD-05 COMM02 JP-2 LD-102 SB-12 SS-16 243 41.33% 588
33 2150 CD-03 COMM02 JP-2 LD-102 SB-12 SS-16 2 100.00% 2
34 2151 CD-05 COMM02 JP-2 LD-102 SB-12 SS-16 36 38.71% 93
35 2200 CD-03 COMM02 JP-3 LD-102 SB-12 SS-16 959 88.39% 1085
36 2204 CD-05 COMM02 JP-3 LD-102 SB-12 SS-16 363 90.07% 403
37 2205 CD-03 COMM02 JP-3 LD-102 SB-12 SS-16 921 90.38% 1019
38 2206 CD-05 COMM02 JP-3 LD-102 SB-12 SS-16 704 45.77% 1538
Is there any way to move the 100% to the top
when the colorkey legend prints?
spplot(tx3_sp, c("CK_PCT"),
names.attr = c("Carol Kent 2008"),
colorkey=list(height=1.0, width=0.6),
main = "HD102 - Carol Kent",
sp.layout = list("sp.text",coordinates(tx3_sp),
as.character(tx3_sp$PCT,cex = .02),
as.table = TRUE))
See the attached jpg file. I hope this goes through.
Forgive my dumb question as I am new to R. I like
R after reading the NYTIMES article last week;
"Data Analysts Mesermized by Power of R". Query
the NYTIMES for this. And read the "Are U Ready
for R" article with its comments as well.
Thanks,
Jim Burke
------------------------------------------------------------------------
------------------------------------------------------------------------
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Edzer Pebesma Institute for Geoinformatics (ifgi), University of M?nster Weseler Stra?e 253, 48151 M?nster, Germany. Phone: +49 251 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de/ http://www.springer.com/978-0-387-78170-9 e.pebesma at wwu.de