我使用R鍵在地圖上繪製一些座標,使用下面的代碼:沒有非缺失參數MIN和MAX
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)
當我運行此代碼,我得到這樣的警告:
警告消息: 1:在min(x)中:沒有非缺少參數min;返回Inf 2:在max(x)中:沒有非缺失參數爲max;返回-Inf 3:在min(x)中:沒有非缺少參數min;返回Inf 4:在max(x)中:沒有非缺失參數爲max;返回-Inf
然後代碼顯示座標,但在背景中沒有地圖。我環顧四周,這個錯誤發生在其他人身上,但我看到的解決方案似乎並不適合我的具體問題。 我正在使用this dataset from kaggle的較小的已清理版本,該版本在我使用的目標經度和緯度上沒有空值或NA,並且根本沒有NA。
我的數據結構:
'data.frame': 13 obs. of 20 variables:
$ mission.id : int 1 2 3 4 5 6 7 8 9 10 ...
$ mission.date : Factor w/ 1 level "15/08/1943": 1 1 1 1 1 1 1
1 1 1 ...
$ theater.of.operations : Factor w/ 4 levels "CBI","ETO","MTO",..: 3 4
3 3 4 4 4 4 3 3 ...
$ country : Factor w/ 2 levels "GREAT BRITAIN",..: 2 2 2
2 2 2 2 2 2 2 ...
$ air.force : Factor w/ 4 levels "10 AF","12 AF",..: 2 3 2
2 3 3 3 3 2 2 ...
$ aircraft.series : Factor w/ 4 levels "A36","B17","B24",..: 1 3
1 1 3 3 3 2 1 1 ...
$ mission.type : Factor w/ 4 levels "OBJECTIVE BOMBING",..: 4
1 4 4 1 1 3 1 4 4 ...
$ takeoff.base : Factor w/ 2 levels "PONTE OLIVO AIRFIELD",..:
1 2 1 1 2 2 2 2 1 1 ...
$ takeoff.location : Factor w/ 2 levels "SICILY","UNKNOWN": 1 2 1
1 2 2 2 2 1 1 ...
$ target.id : Factor w/ 6 levels "16140","3735",..: 4 6 5 1
6 6 6 6 3 1 ...
$ target.country : Factor w/ 5 levels "BURMA","GERMANY",..: 3 4
3 3 5 4 4 4 3 3 ...
$ target.city.or.area : Factor w/ 10 levels "BERLIN","COSENZA",..: 10
6 2 3 5 4 8 8 9 3 ...
$ target.type : Factor w/ 5 levels "AIRDROME","CITY AREA",..:
4 3 4 4 5 4 4 1 4 4 ...
$ target.industry : Factor w/ 3 levels "ARMAMENT AND ORDNANCE
PLANTS",..: 3 3 3 3 3 3 3 3 3 1 ...
$ target.priority : int 9 1 9 9 1 1 1 1 9 9 ...
$ target.latitude : num 38.22 -7.17 39.27 38.43 -1.12 ...
$ target.longitude : num 15.4 147 16.2 15.9 103.9 ...
$ altitude..hundreds.of.feet.: int 139 44 139 139 60 35 70 40 139 139 ...
$ source.id : Factor w/ 9 levels "11287","11326",..: 9 8 9
9 3 7 1 2 9 9 ...
$ bomb.type : Factor w/ 2 levels "HIGH EXPLOSIVES",..: 1 1
1 1 1 1 1 1 1 1 ...
哪一行拋出的錯誤?代碼不涉及明確的'min'或'max'。 –
我在最後四行後得到錯誤,是的,我想也許我必須將它們包括在某處,但我不知道我會在那裏做什麼。 – Niall
你的問題到目前爲止還不是一個[mcve],真的很難說什麼。某些函數(並且您沒有明確指定)不喜歡某些您輸入的輸入(並且我們不知道輸入是什麼)。我們應該猜測問題是什麼? –