Question

I am a total newbie to R and I would like to draw a line (possibly weighted, e.g., by the number of trips made) between two countries. Currently, I use longitude and latitude for each capital to draw a line, but I would like to do it using the package ggmap. I was looking around, but did not find any solution so far. I would appreciate a quick help.

    require(ggmap)
    require (rworldmap)

    all_content = readLines("ext_lt_intratrd_1_Data.csv")
    skip_second = all_content[-2]
    dat = read.csv(textConnection(skip_second), header = TRUE, stringsAsFactors =F)
    dat[5,2]<- c("Germany") # using a data where the first line is
                             header, but second line must be skipped as it is EU 27
                             and not a single country
    europe <- read.csv("eulonglat.csv", header = TRUE) # using world capitals to 
    generate points
    myfulldata <- merge(dat, europe)
    map <- get_map(location = 'Europe', zoom = 4)
    mapPoints <- ggmap(map) + geom_point(aes(x = UNc_longitude, y = UNc_latitude, size 
    = log(myfulldata$Value)), data = myfulldata, col = "red", alpha= 0.5) # this can 
    be plotted
    # i would continue with drawing line and i searched for references
    # i found arrows(42.66,23.34,50.82,4.47) - which did not work 
    # i tried to look for a reference work more, but could not find
    # instead i found it using with the package rworldmap the following
   lines(c(4.47, 23.32), c(50.82, 42.66))
    # this does not work on ggmap

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top