I use the ggmap
package and I want to plot a heat map according to a value and not the records count.
With the help of others posts about same topics, I can approach this goal but the plot is not really a heat map.
I precise that it's not a duplicate of Heatmap plot by value using ggmap and ggmap Heatmap with value because I don't want to facet my plot nor have a choropleth map.
Here is the code and an extract of the data.
The code :
library(ggmap)
CentreCarte <- c(lon = 2.35, lat = 48.85)
Carte <- get_map(location = CentreCarte, source = "google", maptype = "terrain", zoom = 9, color = "bw")
ggmap(Carte) %+% MyData +
aes(x = lon, y = lat, z = Satisfaction) +
stat_summary2d(fun = median, alpha = 0.5)
The data :
structure(list(lon = c(2.336018, 2.336018, 2.5221629, 2.246237,
2.3259213, 2.16647, 2.1203554, 1.735384, 1.940096, 1.765638,
2.2899811, 2.165493, 2.110156, 2.378493, 2.3716529, 2.31002,
2.3827967, 2.3625879, 2.3529867, 2.3719424, 2.4270832, 2.897243,
2.656802, 2.6880829, 2.504403, 2.458625, 3.299203, 2.2785604),
lat = c(48.7022059, 48.7022059, 48.7708784, 48.589172, 48.6408416,
48.6792779, 48.8048649, 48.992181, 48.571308, 48.805027,
48.9162844, 48.990006, 48.880777, 48.997347, 49.093886, 48.796696,
48.8387005, 48.9259577, 48.891305, 48.8111854, 48.9156278,
48.928386, 48.7904005, 48.868659, 48.90852, 48.892489, 48.560149,
48.8399261), Satisfaction = c(5, 4, 1, 4, 3, 3, 2, 3, 5,
1, 4, 3, 1, 5, 3, 3, 3, 2, 3, 4, 2, 3, 3, 1, 2, 2, 5, 4)), .Names = c("lon",
"lat", "Satisfaction"), row.names = c(560L, 561L, 565L, 566L,
569L, 570L, 573L, 574L, 576L, 581L, 594L, 597L, 599L, 600L, 601L,
605L, 606L, 607L, 608L, 609L, 611L, 612L, 615L, 616L, 619L, 622L,
623L, 624L), class = "data.frame")