欢迎来到StackOverflow!为了帮助人们帮助你,你应该努力提供一个 可重复的例子 。例如,这里将是您的数据的一个小代码摘录:
library(tidyverse) Anatomy <- tribble(~Species, ~Lat, ~Long, ~Station, "A", 50, 60, "I", "A", 50, 60, "I", "A", 40, 30, "II", "B", 50, 60, "I", "B", 40, 30, "II")
您的数据/代码存在一些问题:
st_transform
sf
Anatomy$Latitude
Latitude
latitude
lat
count()
这是一段代码。注意我只是反转(60,50)到(-60,-50)这显然是错误的!
library(ggmap) #> Loading required package: ggplot2 #> Google's Terms of Service: https://cloud.google.com/maps-platform/terms/. #> Please cite ggmap if you use it! See citation("ggmap") for details. library(tidyverse) B<-get_map(location = c(lon = -56.731405, lat =-61.4831206), zoom = 6, scale = "auto", maptype = c("terrain"), source = c("google")) library(tidyverse) Anatomy <- tribble(~Species, ~Lat, ~Long, ~Station, "A", 50, 60, "I", "A", 50, 60, "I", "A", 40, 30, "II", "B", 50, 60, "I", "B", 40, 30, "II") Anatomy_clean <- Anatomy %>% mutate_at(c("Lat", "Long"), funs(-1*.)) %>% count(Species, Lat, Long, Station) #> Warning: funs() is soft deprecated as of dplyr 0.8.0 #> please use list() instead #> #> # Before: #> funs(name = f(.) #> #> # After: #> list(name = ~f(.)) #> This warning is displayed once per session. ggmap(B) + geom_point(data=Anatomy_clean, aes(x= Lat,y=Long, color=Species, size= n)) + scale_size_continuous(range=c(1,12)) #> Warning: Removed 2 rows containing missing values (geom_point).