R Studio中使用ggmap和ggplot2的热图-应用于连续比例的离散值
我正试图在R工作室根据房屋的销售价格,绘制一张房屋的lon/lat热图 我的数据是这样的:R Studio中使用ggmap和ggplot2的热图-应用于连续比例的离散值,r,ggplot2,heatmap,R,Ggplot2,Heatmap,我正试图在R工作室根据房屋的销售价格,绘制一张房屋的lon/lat热图 我的数据是这样的: > head(data) SellPrice longitude lattitude 1 577401 -111.9373 33.412658 2 586708 -111.7429 33.391641 3 534415 -111.7474 33.460230 4 634607 -112.0530 33.607888 5 489025 -112.0535 33.522
> head(data)
SellPrice longitude lattitude
1 577401 -111.9373 33.412658
2 586708 -111.7429 33.391641
3 534415 -111.7474 33.460230
4 634607 -112.0530 33.607888
5 489025 -112.0535 33.522867
6 593311 -112.0591 33.521361
这就是我试图展示的方式:
map <- get_map(location='united states', zoom=4, maptype = 'terrain', source='google', color='color')
ggmap(map) + geom_point(
aes(x=longitude, y=latitude, colour=SellPrice), data=data, alpha=.5 ) +
scale_color_gradient(low="beige", high="red")
知道我错过了什么吗?总的来说,我对研究和统计都是新手
稍后编辑:
即使我离开这一部分,它仍然不起作用,同样的错误:
ggmap(map) + geom_point(
aes(x=longitude, y=lattitude), data=data, alpha=.5 )
设法把它修好了。只需将我的lat/long数值设为整数,就可以解决这个问题。我只需要确定我的lat/long数值,它们是整数我不确定它是否相同,因为即使我删除了颜色标签,它仍然不起作用我不确定它是否相同,因为即使我删除了颜色标签,它仍然不起作用当它们在样本数据中的点超过小数点时,它们怎么可能是整数?当它们在样本数据中的点超过小数点时,它们怎么可能是整数?
ggmap(map) + geom_point(
aes(x=longitude, y=lattitude), data=data, alpha=.5 )