R 最小值和最大值没有未丢失的参数
我使用R在地图上绘制一些坐标,使用以下代码:R 最小值和最大值没有未丢失的参数,r,ggplot2,ggmap,R,Ggplot2,Ggmap,我使用R在地图上绘制一些坐标,使用以下代码: library(ggplot2) library(ggmap) smalloperations <- read.csv("S:/smalloperations.csv", na.strings=c("","NA")) lon <- c(smalloperations$target.longitude) lat <- c(smalloperations$target.latitude) df <- as.data.frame
library(ggplot2)
library(ggmap)
smalloperations <- read.csv("S:/smalloperations.csv", na.strings=c("","NA"))
lon <- c(smalloperations$target.longitude)
lat <- c(smalloperations$target.latitude)
df <- as.data.frame(cbind(lon,lat))
# getting the map
mapgilbert <- get_map(location = c(lon = mean(df$lon), lat = mean(df$lat)),
zoom = 1, maptype = "satellite", scale = 2)
# plotting the map with some points on it
ggmap(mapgilbert) +
geom_point(data = df, aes(x = lon, y = lat, fill = "red", alpha = 0.8), size
= 5, shape = 21) +
guides(fill=FALSE, alpha=FALSE, size=FALSE)
zoom是一个3-20的整数,您使用的是1,没有可复制的答案,所以我不能确定。但是(可能)在hablar方案中有一个解决方案。R中的平均值不适用于NA,Inf。在lat和lon上添加s函数将提供:
library(ggplot2)
library(ggmap)
library(hablar)
smalloperations <- read.csv("S:/smalloperations.csv", na.strings=c("","NA"))
lon <- c(smalloperations$target.longitude)
lat <- c(smalloperations$target.latitude)
df <- as.data.frame(cbind(lon,lat))
# getting the map
mapgilbert <- get_map(location = c(lon = mean(s(df$lon)), lat = mean(s(df$lat))),
zoom = 1, maptype = "satellite", scale = 2)
# plotting the map with some points on it
ggmap(mapgilbert) +
geom_point(data = df, aes(x = lon, y = lat, fill = "red", alpha = 0.8), size
= 5, shape = 21) +
guides(fill=FALSE, alpha=FALSE, size=FALSE)
库(ggplot2)
图书馆(ggmap)
图书馆(hablar)
smalloperations哪行抛出错误?代码没有明确地涉及min
或max
。我在最后四行之后得到了错误,是的,我想也许我必须在某个地方包含它们,但我不知道我会在哪里这样做。你的问题远不是一个问题,真的很难说。某些函数(您没有指定哪个函数)不喜欢您提供给它的某些输入(我们不知道输入是什么)。我们应该猜猜问题出在哪里吗?阅读本文可能会有所帮助:。因为您没有向我们显示您的数据-至少显示您的dataframe结构str(df)
,然后以更合适的方式设置您的data.frame,例如,df这不是问题的答案,因此应添加为注释。但如果数据中有NAs,则说明了为什么没有映射。有点像鸡/蛋的事,不是吗?我只是说说而已。参见:特别是关于回答问题的部分。你的答案在评论堆栈中被标记为“非答案”,我只是想通知你。这里的政策不是我制定的;-)啊-有道理。改变了答案。
library(ggplot2)
library(ggmap)
library(hablar)
smalloperations <- read.csv("S:/smalloperations.csv", na.strings=c("","NA"))
lon <- c(smalloperations$target.longitude)
lat <- c(smalloperations$target.latitude)
df <- as.data.frame(cbind(lon,lat))
# getting the map
mapgilbert <- get_map(location = c(lon = mean(s(df$lon)), lat = mean(s(df$lat))),
zoom = 1, maptype = "satellite", scale = 2)
# plotting the map with some points on it
ggmap(mapgilbert) +
geom_point(data = df, aes(x = lon, y = lat, fill = "red", alpha = 0.8), size
= 5, shape = 21) +
guides(fill=FALSE, alpha=FALSE, size=FALSE)