0

Here is the code I'm trying to run:

ch4_useful_data <- ch4_data %>%
  select("CH4 (ppm)", "Latitude", "Longitude")

followed by:

Map <- get_map(location=c(lon = -79.15784454, lat = 40.61871338), source="google", maptype="satellite", zoom=16)
Map_Plot <- ggmap(Map, extent = "panel", ylab = "Latitude", xlab = "Longitude")
Map_Plot + geom_point(data = chr_data, aes(x = longitude, y = latitude, color = "CH4 (ppm)"), size = 8, alpha = 0.5) scale_color_gradient(colours = myPalette(100), limits = c(2, 15), name = "[CH4] ppm") +
  labs( y = "Latitude", x = "Longitude", title = "Methane Map")

This latter chunk returns:

"Error: unexpected symbol in "Map_Plot + geom_point(data = chr_data, aes(x = longitude, y = latitude, color = "CH4 (ppm)"), size = 8, alpha = 0.5) scale_color_gradient"

I've been staring at it for an hour, what character is unexpected here? Or is it a deeper issue related to something like data formatting from a previous step?

Mako212
  • 6,787
  • 1
  • 18
  • 37
Seanie_13
  • 21
  • 6
  • There is a lot of help available on SO, but you have to provide a bit more information for the best possible answers. Read about how to ask questions for R on SO here: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Kat Jul 02 '21 at 16:48

1 Answers1

0

There was a + missing before scale_color_gradient. Also, specify the column name in backquotes where there are spaces in the name

Map_Plot  +
     geom_point(data = chr_data, aes(x = longitude, y = latitude, color = `CH4 (ppm)`), size = 8, alpha = 0.5) + 
     scale_color_gradient(colours = myPalette(100), limits = c(2, 15), name = "[CH4] ppm") +
  labs( y = "Latitude", x = "Longitude", title = "Methane Map")
akrun
  • 874,273
  • 37
  • 540
  • 662