I have the following data for a US state
d <- structure(list(Month = structure(c(5L, 4L, 9L, 1L, 8L, 7L, 6L,
2L, 12L, 11L, 10L, 3L), .Label = c("01-Abr-14", "01-Ago-14",
"01-Dez-14", "01-Fev-14", "01-Jan-14", "01-Jul-14", "01-Jun-14",
"01-Mai-14", "01-Mar-14", "01-Nov-14", "01-Out-14", "01-Set-14"
), class = "factor"), Ada = c(0.1, 0.14, 0.25, -0.06, -0.15,
0.3, 0.02, -0.01, 0.37, 0.08, 0.15, 0.17), Altus = c(0.06, 0.05,
0.1, -0.17, -0.02, 0.25, -0.02, 0.08, 0, 0.02, 0.02, 0.02), Antlers = c(-0.08,
0.02, 0.1, -0.38, -0.3, 0.27, -0.17, -0.1, 0.11, 0.11, 0.14,
0), Ardmore = c(-0.01, 0.09, 0.18, -0.24, 0.02, 0.21, -0.13,
-0.06, 0.18, 0.01, -0.02, 0.08), Bartlesville = c(-0.02, 0.09,
0.2, 0.16, -0.07, 0.08, 0.01, 0.04, -0.01, 0.11, 0.11, 0.15),
Beaver = c(0.01, -0.02, 0.16, -0.08, -0.04, 0.07, 0.07, 0.07,
-0.12, 0.05, 0, 0.05), Boise.City = c(0.02, -0.05, 0.09,
-0.1, -0.24, 0.05, -0.01, 0.21, -0.01, -0.06, 0, 0.03), Buffalo = c(-0.04,
0, 0.15, -0.05, -0.15, 0.16, -0.11, 0.12, -0.2, 0.03, 0,
0.01), Carnegie = c(0.02, 0.06, 0.15, -0.16, 0.09, 0.24,
-0.03, 0.09, -0.16, 0.06, -0.01, 0), Cherokee = c(0.06, 0.1,
0.26, -0.1, -0.06, 0.2, 0.06, -0.06, -0.06, -0.11, 0, 0.08
), Claremore = c(-0.02, 0.22, 0.18, 0.12, -0.09, 0.11, 0.16,
0.04, 0.46, 0.16, 0.25, 0.17), Durant = c(0.06, 0.05, 0.15,
-0.11, -0.12, 0.35, -0.21, 0, 0.4, 0.04, 0.26, 0.09), Enid = c(0.07,
0.08, 0.34, 0, 0.18, 0.34, 0.11, 0.09, -0.04, 0.17, 0.13,
0.1), Erick = c(0.05, 0.06, 0.14, -0.15, -0.09, 0.07, -0.05,
0.13, 0.01, -0.02, 0.04, 0.02), Geary = c(-0.01, 0.01, 0.15,
-0.19, -0.09, 0.14, -0.18, 0.14, 0.02, 0.05, -0.07, 0), Goodwell = c(0,
-0.05, 0.08, -0.08, -0.01, 0, -0.06, 0.03, -0.12, 0.02, -0.03,
0), Guthrie = c(0.06, 0.13, 0.23, -0.09, 0.06, 0.31, -0.03,
0.05, -0.01, 0.03, 0.09, 0.11), Hammon = c(0.02, 0.03, 0.14,
-0.2, -0.04, 0.1, -0.1, 0.23, -0.07, 0.05, 0.03, 0.03), Hennessey = c(0.02,
0.09, 0.22, -0.04, 0.1, 0.22, 0.13, 0.2, 0.08, -0.01, 0.03,
0.07), Hobartmuni = c(-0.03, -0.02, 0.1, -0.17, -0.29, -0.08,
0.02, 0.04, -0.05, -0.03, 0, 0), Holdenville = c(-0.04, 0.12,
0.26, 0.05, -0.16, 0.23, 0.04, 0.01, 0.27, 0.13, 0.12, 0.07
), Hooker = c(0.03, -0.03, 0.07, -0.08, -0.17, 0.01, -0.03,
-0.05, -0.14, -0.02, 0, 0.04), Jefferson = c(0.04, 0.05,
0.29, 0.09, 0.05, 0.21, 0.11, 0.07, -0.03, 0.05, 0.09, 0.08
), Kenton = c(0.02, -0.06, 0.05, -0.12, -0.15, 0, 0.27, 0.17,
-0.01, -0.04, -0.02, -0.01), Kingfisher = c(0.05, 0.09, 0.18,
-0.02, 0.19, 0.21, -0.03, 0.19, 0.1, -0.01, 0.02, 0.11),
Lawton = c(0.03, 0.06, 0.06, -0.17, -0.39, 0.11, -0.1, 0.06,
0, 0.06, 0.03, 0.03), Mangum = c(0.01, 0, 0.05, -0.31, -0.27,
0.13, 0.01, -0.01, -0.01, 0, 0, 0.01), Meeker = c(-0.03,
0.14, 0.22, -0.15, -0.03, 0.34, 0.05, -0.03, 0.22, 0.14,
0.02, 0.06), Miami = c(-0.03, 0.03, 0.17, 0.12, 0.15, -0.11,
-0.15, -0.29, 0.34, 0.11, 0.25, 0.09), Muskogee = c(0.08,
0.12, 0.14, -0.04, 0.27, 0.16, -0.09, -0.07, 0.36, -0.02,
0.23, 0.14), Mutual = c(0.04, 0.05, 0.16, -0.05, 0.2, 0.16,
0.06, -0.04, -0.1, 0.02, 0, 0.08), Newkirk = c(-0.04, 0.06,
0.19, 0.13, -0.09, 0.15, 0.24, -0.01, -0.1, 0.21, 0, 0.1),
Okeene = c(0.09, 0.19, 0.12, 0.06, 0.02, 0.41, 0.03, 0.03,
0.37, 0.08, 0.13, 0.17), Okemah = c(0, 0.04, 0.2, -0.08,
0.04, 0.12, 0.05, 0.04, -0.01, 0.1, 0, 0.06), Okmulgee = c(0.04,
0.21, 0.17, -0.02, 0.01, 0.23, 0.03, 0.06, 0.17, 0, 0.29,
0.1), Pauls_valley = c(0.17, 0.17, 0.36, -0.02, -0.11, 0.27,
-0.12, 0.06, 0.27, 0.22, 0.13, 0.21), Pawhuska = c(0.05,
0.11, 0.3, 0.29, 0.19, 0.13, 0.2, -0.02, 0.1, 0.12, 0.2,
0.15), Perry = c(0.04, 0.13, 0.25, -0.15, -0.06, 0.02, 0.2,
-0.15, -0.05, 0, -0.04, 0.07), Poteau = c(-0.03, 0.05, 0.21,
-0.11, -0.01, -0.07, -0.11, -0.15, 0.37, 0.39, 0.25, 0.2),
Stillwater = c(0.04, 0.12, 0.16, -0.2, -0.04, 0.2, 0.1, -0.01,
0.02, 0, 0, 0.05), Tahlequah = c(0.09, 0.17, 0.27, -0.02,
0.48, 0.06, 0.28, 0.05, 0.38, 0.11, 0.4, 0.21), Waurika = c(0.07,
0.04, 0.16, -0.09, -0.12, 0.08, -0.22, -0.01, 0.09, 0.09,
-0.03, 0.02), Weatherford = c(0.03, 0.05, 0.23, -0.24, -0.06,
0.25, -0.11, 0.3, -0.1, 0.04, -0.03, 0.01), Webbersfalls = c(-0.04,
0.1, 0.16, -0.09, 0.09, -0.01, -0.25, -0.18, 0.39, 0.01,
0.3, 0.11)), .Names = c("Month", "Ada", "Altus", "Antlers",
"Ardmore", "Bartlesville", "Beaver", "Boise.City", "Buffalo",
"Carnegie", "Cherokee", "Claremore", "Durant", "Enid", "Erick",
"Geary", "Goodwell", "Guthrie", "Hammon", "Hennessey", "Hobartmuni",
"Holdenville", "Hooker", "Jefferson", "Kenton", "Kingfisher",
"Lawton", "Mangum", "Meeker", "Miami", "Muskogee", "Mutual",
"Newkirk", "Okeene", "Okemah", "Okmulgee", "Pauls_valley", "Pawhuska",
"Perry", "Poteau", "Stillwater", "Tahlequah", "Waurika", "Weatherford",
"Webbersfalls"), class = "data.frame", row.names = c(NA, -12L
))
coordinates for each place to map
coords <- structure(list(place = structure(c(2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L,
35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 1L, 44L), .Label = c(" Weatherford",
"Ada", "Altus", "Antlers", "Ardmore", "Bartlesville", "Beaver",
"Boise City", "Buffalo", "Carnegie", "Cherokee", "Claremore",
"Durant", "Enid", "Erick", "Geary", "Goodwell", "Guthrie", "Hammon",
"Hennessey", "Hobartmuni", "Holdenville", "Hooker", "Jefferson",
"Kenton", "Kingfisher", "Lawton", "Mangum", "Meeker", "Miami",
"Muskogee", "Mutual", "Newkirk", "Okeene", "Okemah", "Okmulgee",
"Pauls_valley", "Pawhuska", "Perry", "Poteau", "Stillwater",
"Tahlequah", "Waurika", "Webbersfalls"), class = "factor"), Lat = c(34.7864,
34.5903, 34.2208, 34.1714, 36.7683, 36.8125, 36.7236, 36.8003,
35.1756, 36.7747, 36.3225, 34.0003, 36.4194, 35.2164, 35.6267,
36.5914, 35.8161, 35.585, 36.0942, 34.9894, 35.0567, 36.8589,
36.7222, 36.9031, 35.8583, 34.6097, 34.8911, 35.505, 36.8833,
35.7781, 36.2283, 36.8914, 36.1217, 35.4253, 35.6239, 34.7253,
36.6692, 36.2886, 35.0539, 36.1175, 35.9369, 34.1747, 35.52,
35.4814), Long = c(-96.685, -99.3344, -95.615, -97.1294, -96.0261,
-100.5308, -102.4806, -99.6403, -98.5794, -98.3583, -95.5808,
-96.3686, -97.8747, -99.8628, -98.3225, -101.6181, -97.395, -99.3953,
-97.835, -99.0525, -96.3861, -101.2172, -97.7903, -102.965, -97.9294,
-98.4572, -99.5017, -96.9767, -94.8833, -95.3339, -99.17, -97.0586,
-98.315, -96.3033, -96.025, -97.2814, -96.3472, -97.2897, -94.6264,
-97.095, -94.9644, -97.9964, -98.6986, -95.2039)), .Names = c("place",
"Lat", "Long"), class = "data.frame", row.names = c(NA, -44L))
So basically I want to take the values, find out which one is positive and which one is negative and plot a figure like below.
- There will be three different tickers for +,- and zero
- 12 facets for 12 months
I have the lat/longs for the 44 places, so I can plot them on the state map.
How can I do this using ggplot2? or some other utility.
Till now, I have plotted the points using the following code
ggplot() +
geom_polygon(data=m, aes(x=long, y=lat,group=group),colour="black", fill="white" )+
geom_point(data=stations,aes(x=long,y=lat),,colour="red",)+
size=0.5,hjust=0,alpha=.5),size=3)+
xlab('Longitude')+
ylab('Latitude')+
coord_fixed()