R 合并:‘;不适用‘;NA’;在结果中是重复的

R 合并:‘;不适用‘;NA’;在结果中是重复的,r,R,我正在查看此链接中的示例代码 看起来数据集的位置发生了变化,所以我稍微修改了代码以适应这些变化 airports <- read.delim("https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat", sep=",") colnames(airports) <- c("ID", "name", "city", "country", "IATA_FAA", "ICAO", "la

我正在查看此链接中的示例代码

看起来数据集的位置发生了变化,所以我稍微修改了代码以适应这些变化

airports <- read.delim("https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat", sep=",")
colnames(airports) <- c("ID", "name", "city", "country", "IATA_FAA", "ICAO", "lat", "lon", "altitude", "timezone", "DST")
head(airports)

library(rworldmap)
newmap <- getMap(resolution = "low")
plot(newmap, xlim = c(-20, 59), ylim = c(35, 71), asp = 1)
points(airports$lon, airports$lat, col = "red", cex = .6)



routes <- read.csv("https://raw.githubusercontent.com/jpatokal/openflights/master/data/routes.dat", header=F)
colnames(routes) <- c("airline", "airlineID", "sourceAirport", "sourceAirportID", "destinationAirport", "destinationAirportID", "codeshare", "stops", "equipment")
head(routes)

library(plyr)
departures <- ddply(routes, .(sourceAirportID), "nrow")
names(departures)[2] <- "flights"
arrivals <- ddply(routes, .(destinationAirportID), "nrow")
names(arrivals)[2] <- "flights"

机场首先,这些只是警告,不是错误。也就是说,一切仍然有效,但可能并非如预期的那样。问题源于

colnames(airports) <- c("ID", "name", "city", "country", "IATA_FAA", "ICAO", "lat", "lon", "altitude", "timezone", "DST")

colnames(机场)啊,是的!!这是有道理的。我做了你推荐的改变,现在一切都很好。像往常一样,我试图自己解决这个问题,这样我就不必问一个愚蠢的问题,但这个问题让我逃避了。再次感谢!!
colnames(airports) <- c("ID", "name", "city", "country", "IATA_FAA", "ICAO", "lat", "lon", "altitude", "timezone", "DST")