1

I would like to add price labels to a map of apartment listings I created using geom_point, however the labels won't show up and I get this error:

Error: Aesthetics must be either length 1 or the same as the data (4): label

How can I add the labels to points? I know there are other similar questions out there, but the solutions have so far not worked.

My data is structured as shown in this photo:

photo

df2Map <- ggmap(get_map("Brooklyn, zoom = 13)")) 

df2Map + 
  geom_point(data = df2, 
             aes(x = df2$Longitude, y = df2$Latitude)) + 
  geom_label(aes(label = df2$Price))
Z.Lin
  • 28,055
  • 6
  • 54
  • 94
Byron Pop
  • 31
  • 1
  • 8
  • 1
    "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." And pictures/screenshots do not count as data. – IRTFM Mar 01 '19 at 23:27
  • 1
    `ggplot` calls should omit the `df2$` part you have here in three places, and just use the column name. That might fix your error. – Jon Spring Mar 02 '19 at 00:49
  • 1
    In addition, try replacing the last line with `geom_label(data = df2, aes(x = Longitude, y = Latitude, label = Price))` – Z.Lin Mar 02 '19 at 02:07
  • Z.Lin that fixed it. Thanks so much guys! – Byron Pop Mar 02 '19 at 15:32
  • Possible duplicate of [Issue when passing variable with dollar sign notation ($) to aes() in combination with facet\_grid() or facet\_wrap()](https://stackoverflow.com/questions/32543340/issue-when-passing-variable-with-dollar-sign-notation-to-aes-in-combinatio) – Arthur Yip Mar 04 '19 at 05:26

0 Answers0