gpt4 book ai didi

r - 错误 : Discrete value supplied to continuous scale

转载 作者:行者123 更新时间:2023-12-03 20:04:26 30 4
gpt4 key购买 nike

我正在使用 ggmap 处理马达加斯加 map

myMap <- get_map(location=k, source="stamen", maptype="toner", crop=FALSE, 
zoom=16)

并根据 x y 纬度/经度网格在该 map 上绘制点

ggmap(myMap) + geom_point(data=GPS, aes(x = 'Lon', y ='Lat'))
ggplot(data=GPS, aes(x=Lon,y=Lat)) + geom_point()

从看起来像这样的数据

 Tree.ID       Type       Species       Lat      Lon Foraged Plot
7 deadwood Dracaena -21.37413 47.86700 N 1
8 deadwood Bivinia -21.37408 47.86696 N 1
9 deadwood Beilschmiedia -21.37396 47.86691 N 1
10 live trunk Ocotea -21.37410 47.86690 N 1
12 deadwood Tambourissa -21.37418 47.86696 N 1
13 live trunk Canarium -21.37422 47.86691 N 1

但是我得到这个错误:

Error: Discrete value supplied to continuous scale

我该怎么办?

最佳答案

您将字符串 "Lon""Lat" 传递给 xy 而不是而不是传递 LonLat 本身。去掉引号,你应该没问题。

d <- read.table(header=T, text='
Tree.ID Type Species Lat Lon Foraged Plot
7 deadwood Dracaena -21.37413 47.86700 N 1
8 deadwood Bivinia -21.37408 47.86696 N 1
9 deadwood Beilschmiedia -21.37396 47.86691 N 1
10 livetrunk Ocotea -21.37410 47.86690 N 1
12 deadwood Tambourissa -21.37418 47.86696 N 1
13 livetrunk Canarium -21.37422 47.86691 N 1')

library(ggmap)

myMap <- get_map(location=colMeans(d[, c('Lon', 'Lat')]), source="stamen",
maptype="toner", crop=FALSE, zoom=16)
ggmap(myMap) + geom_point(aes(x = Lon, y = Lat), data=d)

enter image description here

关于r - 错误 : Discrete value supplied to continuous scale,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24121837/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com