I am using following data set:
head(trip_3)
TIP LON LAT
1 0 -73.866 40.741
2 10.0 -73.906 40.707
3 1.2 -73.706 40.738
4 2.0 -73.946 40.640
5 0 -73.946 40.625
6 1.5 -73.986 40.602
I was able to generate following map to present points with high and low average tip values:
I have achieved it with following code:
nyc_map + geom_point(data=as.data.frame(trip_3), aes(x=LON, y=LAT, fill=TIP), size=3,
shape=21, alpha=0.6, position="jitter") + scale_fill_continuous(low="white", high="#FF0033")
Now I want to get a map presenting areas (density) with high and low tips but not using points - I want to get something like this:
But it counts amount of points, not bases on TIP value. It would be great to achieve what I have described earlier. It is the code I used:
nyc_map + stat_density2d(aes(x=LON, y=LAT, fill = ..level..), size=3,
bins=10, data=as.data.frame(trip_3), geom="polygon")
How to make stat_density2d rely on TIP, not amount of points?