R 向ggmake plot添加点时出错
我正在尝试使用ggmake创建一个绘图,该绘图已创建,但我想使用geom_point添加点,为此我给出了城市的经度和纬度,但由于错误未能实现,下面我粘贴了包含经度和纬度的代码和数据框R 向ggmake plot添加点时出错,r,maps,ggmap,R,Maps,Ggmap,我正在尝试使用ggmake创建一个绘图,该绘图已创建,但我想使用geom_point添加点,为此我给出了城市的经度和纬度,但由于错误未能实现,下面我粘贴了包含经度和纬度的代码和数据框 City Longitude Latitude Mastung 66.84691 29.4087 Khuzdaar 66.611691 27.812 Khaich 63.01475 26.156 Panjgore 64.112336 26.97524 Quetta 66
City Longitude Latitude
Mastung 66.84691 29.4087
Khuzdaar 66.611691 27.812
Khaich 63.01475 26.156
Panjgore 64.112336 26.97524
Quetta 66.998734 30.1829713
Dera Bugti 69.159609 29.035158
Kohlo 69.24901 29.8975
Kalat 66.5878 29.0303
Kharaan 65.4222 28.5812
Nooshki 66.0195 29.555
kl <- read.csv(file.choose())
map <- get_map(location=c(66.214995,28.538837), zoom=7) + geom_point(data =
kl,aes(x =longitude,y = latitude,size =4),color='red')
Error:Error in Ops.raster(get_map(location = c(66.214995, 28.538837), zoom = 7),
: operator not meaningful for raster objects
如何绘制这些点并消除此错误
kl <- read.table(text='
City longitude latitude
"Mastung" 66.84691 29.4087
"Khuzdaar" 66.611691 27.812
"Khaich" 63.01475 26.156
"Panjgore" 64.112336 26.97524
"Quetta" 66.998734 30.1829713
"Dera Bugti" 69.159609 29.035158
"Kohlo" 69.24901 29.8975
"Kalat" 66.5878 29.0303
"Kharaan" 65.4222 28.5812
"Nooshki" 66.0195 29.555
', header=T)
library(ggmap)
mp <- get_map(location=c(66.214995,28.538837), zoom=7)
ggmap(mp) +
geom_point(data=kl, aes(x=longitude, y=latitude), color='red', size=4)
谢谢你的回答,但图表并没有显示右边两个地区的名称,城市栏中的名称如何与地图上的点一起打印?因为如果我增加缩放,那么一些区域将从图像中消失?@AmmarSabirCheema这是地图的问题,而不是代码的问题。我很抱歉。请考虑接受并接受我的回答,谢谢。