I am new to R programming and have been trying to plot places (airports) in a map. I am using RStudio (2024.04.2 Build 764) and R (4.4.1).
The datasets are getting populated properly as I can see from the Environment Data tab in RStudio.
library(ggplot2)
library(ggrepel)
library(dplyr)
library(ggmap)
library(corrr)
flights <- read.csv("Flights.csv", stringsAsFactors = FALSE)
airports <- read.csv("Airports.csv")
flights <- merge(flights, airports, by.x="To", by.y="destin")
flights <- merge(flights, airports, by.x="From", by.y="airport")
worldmap <- borders("world", colour="#efede1", fill="#efede1")
But in the actual map plotting using ggplot(), I am getting the error “Error in calcCurveGrob(x, x$debug) : end points must not be identical”. The Plot window in RStudio is showing a white blank screen.
Below is the ggplot code:
ggplot() + worldmap +
geom_curve(data=flights, aes(x = lon.x, y = lat.x, xend = lon.y, yend = lat.y), col = "#b29e7d", size = 1, curvature = .2) +
geom_point(data=airports, aes(x = lon, y = lat), col = "#970027") +
geom_text_repel(data=airports, aes(x = lon, y = lat, label = airport), col = "black", size = 2, segment.color = NA) +
theme(panel.background = element_rect(fill="white"),
axis.line = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank()
)
Any help from this forum will be highly appreciated.
Thanks