I want to have a map representing the distribution of values over an area with some scale. Here is my data frame:
head(trip)
TIP LON LAT
1 1.318878 -73.9932 40.7223
2 1.370667 -73.9932 40.7222
3 0.933232 -73.9772 40.7559
4 1.268699 -73.9932 40.7628
5 1.265304 -73.9932 40.7429
6 1.193437 -73.9852 40.7447
I created a map using the following code:
map <- ggmap::get_map("new york", zoom = 11)
nyc_map <- ggmap::ggmap(map, legend="topleft")
This map is displayed correctly.
I also created a layer with my data view:
ggplot(aes(LON,LAT, fill = TIP), data=as.data.frame(trip)) +
geom_tile() +
scale_fill_continuous(low="white", high="blue") +
coord_equal()
And it is also generated and displayed.
The problem is when I want to do this:
nyc_map +
ggplot(aes(LON,LAT, fill = TIP), data=as.data.frame(trip)) +
geom_tile() +
scale_fill_continuous(low="white", high="blue") +
coord_equal()
I get the following error:
Error in p + o : non-numeric argument to binary operator
In addition: Warning message:
Incompatible methods ("+.gg", "Ops.data.frame") for "+"
I would be grateful if you could help me join these two facilities.