R中城市的热图?

时间:2018-10-30 00:19:28

标签: r maps ggmap

我有一个加利福尼亚大部分城市的数据框,以及该城市每平方英尺租金的中位数价格。我的目标是按城市创建类似于以下内容的热图:

https://www.bizjournals.com/bizjournals/topic/mergers-and-acquisitions

我所看到的所有示例都按州或县划分,所以我想知道是否有可能通过R中的城市mapsggmap来制作热图。

可复制的数据框:

structure(list(city = structure(c(181L, 168L, 109L, 135L, 18L, 
23L, 124L, 185L, 49L, 174L, 165L, 80L, 114L, 137L, 153L, 97L, 
154L, 8L, 193L, 43L, 67L, 164L, 107L, 142L, 149L, 21L, 79L, 46L, 
204L, 192L, 39L, 195L, 189L, 216L, 61L, 131L, 117L, 15L, 211L, 
44L, 115L, 35L, 38L, 176L, 72L, 25L, 105L, 134L, 2L, 199L, 178L, 
123L, 104L, 167L, 74L, 19L, 209L, 116L, 163L, 184L, 3L, 170L, 
152L, 57L, 121L, 146L, 139L, 112L, 27L, 130L, 68L, 53L, 213L, 
128L, 119L, 106L, 147L, 77L, 16L, 91L, 93L, 194L, 41L, 47L, 175L, 
155L, 190L, 198L, 37L, 99L, 31L, 177L, 1L, 200L, 171L, 129L, 
71L, 166L, 70L, 76L, 143L, 28L, 20L, 84L, 26L, 127L, 102L, 62L, 
158L, 126L, 191L, 88L, 140L, 22L, 98L, 50L, 42L, 169L, 186L, 
180L, 51L, 87L, 141L, 12L, 5L, 65L, 95L, 14L, 69L, 182L, 86L, 
133L, 206L, 188L, 205L, 78L, 101L, 159L, 29L, 6L, 58L, 217L, 
92L, 122L, 10L, 17L, 172L, 150L, 183L, 145L, 179L, 214L, 48L, 
52L, 201L, 36L, 138L, 210L, 89L, 208L, 63L, 56L, 148L, 125L, 
66L, 120L, 24L, 7L, 162L, 160L, 90L, 73L, 215L, 196L, 157L, 75L, 
96L, 203L, 60L, 108L, 100L, 151L, 136L, 187L, 30L, 212L, 34L, 
4L, 103L, 144L), .Label = c("Agoura Hills", "Alameda", "Albany", 
"Alhambra", "American Canyon", "Antioch", "Arcadia", "Atherton", 
"Auburn", "Azusa", "Bakersfield", "Baldwin Park", "Bell Gardens", 
"Bellflower", "Belmont", "Belvedere", "Benicia", "Berkeley", 
"Beverly Hills", "Brentwood", "Brisbane", "Burbank", "Burlingame", 
"Calistoga", "Campbell", "Carlsbad", "Carson", "Cerritos", "Chula Vista", 
"Citrus Heights", "Claremont", "Clearlake", "Cloverdale", "Colfax", 
"Colma", "Compton", "Concord", "Coronado", "Corte Madera", "Costa Mesa", 
"Cotati", "Covina", "Culver City", "Cupertino", "Cypress", "Daly City", 
"Danville", "Davis", "Del Mar", "Diamond Bar", "Downey", "Duarte", 
"Dublin", "Dunsmuir", "East Palo Alto", "El Cajon", "El Cerrito", 
"El Monte", "El Segundo", "Elk Grove", "Emeryville", "Encinitas", 
"Escondido", "Fairfax", "Fairfield", "Folsom", "Foster City", 
"Fremont", "Garden Grove", "Gardena", "Gilroy", "Glendale", "Glendora", 
"Half Moon Bay", "Hawaiian Gardens", "Hawthorne", "Hayward", 
"Healdsburg", "Hercules", "Hermosa Beach", "Hillsborough", "Hollister", 
"Huntington Park", "Imperial Beach", "Industry", "Inglewood", 
"La Canada Flintridge", "La Habra", "La Mesa", "La Mirada", "La Palma", 
"La Verne", "Lafayette", "Lakeport", "Lakewood", "Lancaster", 
"Larkspur", "Lemon Grove", "Livermore", "Lodi", "Lomita", "Long Beach", 
"Loomis", "Los Altos", "Los Altos Hills", "Los Angeles", "Los Gatos", 
"Lynwood", "Malibu", "Manhattan Beach", "Manteca", "Martinez", 
"Maywood", "Menlo Park", "Mill Valley", "Millbrae", "Milpitas", 
"Modesto", "Monrovia", "Montebello", "Monterey Park", "Moraga", 
"Morgan Hill", "Mountain View", "Murrieta", "Napa", "National City", 
"Newark", "Norwalk", "Novato", "Oakland", "Oakley", "Oceanside", 
"Orinda", "Pacifica", "Palmdale", "Palo Alto", "Paramount", "Pasadena", 
"Petaluma", "Pico Rivera", "Piedmont", "Pinole", "Pismo Beach", 
"Pittsburg", "Pleasant Hill", "Pleasanton", "Pomona", "Portola Valley", 
"Poway", "Rancho Cordova", "Rancho Palos Verdes", "Redondo Beach", 
"Redwood City", "Richmond", "Rio Vista", "Rocklin", "Rohnert Park", 
"Rosemead", "Roseville", "Ross", "Sacramento", "San Anselmo", 
"San Bruno", "San Carlos", "San Diego", "San Fernando", "San Francisco", 
"San Gabriel", "San Jose", "San Leandro", "San Marcos", "San Marino", 
"San Mateo", "San Pablo", "San Rafael", "San Ramon", "Santa Clara", 
"Santa Clarita", "Santa Fe Springs", "Santa Monica", "Santa Rosa", 
"Santee", "Saratoga", "Sausalito", "Sebastopol", "Sierra Madre", 
"Simi Valley", "Solana Beach", "Sonoma", "South Pasadena", "South San Francisco", 
"St. Helena", "Suisun City", "Sunnyvale", "Temecula", "Temple City", 
"Thousand Oaks", "Tiburon", "Torrance", "Tracy", "Truckee", "Ukiah", 
"Union City", "Vacaville", "Vallejo", "Vernon", "Vista", "Walnut Creek", 
"West Covina", "West Hollywood", "West Sacramento", "Whittier", 
"Windsor", "Woodland", "Woodside", "Yuba City"), class = "factor"), 
    count = c(67L, 1160L, 1L, 81L, 218L, 45L, 489L, 15L, 2L, 
    265L, 33L, 7L, 104L, 153L, 9L, 21L, 297L, 16L, 2L, 12L, 122L, 
    51L, 33L, 5L, 2L, 1L, 7L, 62L, 37L, 25L, 13L, 296L, 8L, 1L, 
    57L, 316L, 140L, 58L, 24L, 221L, 4L, 1L, 12L, 132L, 50L, 
    246L, 4L, 2L, 52L, 12L, 330L, 11L, 4L, 2L, 1L, 9L, 127L, 
    10L, 10L, 4L, 2L, 1095L, 1L, 22L, 1L, 32L, 35L, 12L, 2L, 
    68L, 227L, 91L, 3L, 18L, 9L, 1204L, 111L, 97L, 2L, 1L, 24L, 
    5L, 1L, 12L, 9L, 58L, 8L, 5L, 90L, 40L, 3L, 74L, 2L, 9L, 
    67L, 1L, 27L, 1210L, 1L, 5L, 10L, 4L, 11L, 31L, 69L, 23L, 
    138L, 18L, 54L, 56L, 5L, 2L, 393L, 30L, 6L, 2L, 1L, 4L, 4L, 
    2L, 24L, 3L, 4L, 2L, 44L, 47L, 1L, 3L, 2L, 504L, 39L, 120L, 
    57L, 1L, 86L, 5L, 1L, 2L, 141L, 53L, 5L, 3L, 6L, 8L, 3L, 
    10L, 63L, 13L, 9L, 142L, 85L, 3L, 52L, 1L, 10L, 3L, 12L, 
    77L, 94L, 123L, 98L, 122L, 10L, 1L, 58L, 3L, 1L, 5L, 736L, 
    199L, 1L, 5L, 50L, 5L, 116L, 1L, 44L, 19L, 38L, 8L, 21L, 
    202L, 6L, 1L, 161L, 29L, 2L, 7L, 1L, 1L), med_price_per_sqft = c(5, 
    4.66666666666667, 4.2, 4.18013856812933, 4.08333333333333, 
    4.04, 4.0354609929078, 4, 3.99032710280374, 3.98897058823529, 
    3.9034045922407, 3.9, 3.88116308470291, 3.86, 3.82308845577211, 
    3.7728102189781, 3.76929674099485, 3.74264705882353, 3.69618055555556, 
    3.69573863636364, 3.6831550802139, 3.66666666666667, 3.65625, 
    3.64189189189189, 3.58374792703151, 3.57142857142857, 3.54471544715447, 
    3.53688524590164, 3.51333333333333, 3.50317316409791, 3.5, 
    3.49848942598187, 3.49444444444444, 3.47619047619048, 3.47401774397972, 
    3.45727272727273, 3.41958041958042, 3.37795612133512, 3.363359030837, 
    3.32738095238095, 3.325, 3.27861163227017, 3.27301279122887, 
    3.25824175824176, 3.25573020153278, 3.19213846480068, 3.16583333333333, 
    3.14713463212158, 3.13888888888889, 3.13142307692308, 3.13016006347505, 
    3.11875693673696, 3.09235253435972, 3.09020229468599, 3.06122448979592, 
    3.05555555555556, 3.03627760252366, 3.03591160220994, 3.02625786163522, 
    3.02142857142857, 3.00148762207586, 3.00066844919786, 2.99727272727273, 
    2.99404761904762, 2.99, 2.9879746835443, 2.9375, 2.91209677419355, 
    2.89135365891112, 2.88281549118591, 2.87875, 2.86536675951718, 
    2.85714285714286, 2.81768034308939, 2.79123951537745, 2.77777777777778, 
    2.77522349936143, 2.7669256381798, 2.7543720190779, 2.75, 
    2.74318396226415, 2.73449920508744, 2.71538461538462, 2.69176470588235, 
    2.68461538461538, 2.66907880133185, 2.66666666666667, 2.62635201573255, 
    2.60714285714286, 2.58534136546185, 2.57723577235772, 2.57512015274212, 
    2.56058508446642, 2.54285714285714, 2.53846153846154, 2.52729693741678, 
    2.50523012552301, 2.50461538461538, 2.5, 2.49951690821256, 
    2.46848739495798, 2.45687994200742, 2.45562130177515, 2.45454545454545, 
    2.44368266405485, 2.43348115299335, 2.43055555555556, 2.41045883940621, 
    2.3797619047619, 2.37634408602151, 2.35714285714286, 2.3481943398692, 
    2.34350282485876, 2.33833333333333, 2.32105538140021, 2.31798483206934, 
    2.31152204836415, 2.30769230769231, 2.30625, 2.30615384615385, 
    2.29508196721311, 2.295, 2.27728787668379, 2.27435897435897, 
    2.25362976406534, 2.24403927068724, 2.23076923076923, 2.22444444444444, 
    2.22, 2.21666666666667, 2.21428571428571, 2.20714285714286, 
    2.20436280137773, 2.19209039548023, 2.17721518987342, 2.16666666666667, 
    2.16666666666667, 2.16388888888889, 2.15336134453782, 2.14445479962721, 
    2.13888888888889, 2.125, 2.11339178955759, 2.11327134404057, 
    2.08571428571429, 2.08333333333333, 2.07594936708861, 2.06607929515418, 
    2.06360946745562, 2.05028571428571, 2.04957102001907, 2.04285714285714, 
    2.04259776536313, 2.03725961538462, 2.03240740740741, 2.02255639097744, 
    2.01960784313725, 1.99375, 1.98915298574779, 1.98426966292135, 
    1.97368421052632, 1.88873626373626, 1.85515873015873, 1.84705882352941, 
    1.84639302474793, 1.84375, 1.82352941176471, 1.75, 1.74705882352941, 
    1.74576271186441, 1.7, 1.67493796526055, 1.67179487179487, 
    1.66322314049587, 1.65129682997118, 1.62018255578093, 1.61895360315893, 
    1.61596958174905, 1.61161966161109, 1.60403299725023, 1.60359508041627, 
    1.6, 1.55765441271482, 1.546875, 1.52173913043478, 1.50738916256158, 
    1.43391521197007, 1.41666666666667, 1.39547413793103, 1.03448275862069
    )), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
-190L))

0 个答案:

没有答案