Short version: when you run the following command, the qtm(countries, "freq")following error message appears:
The error is in $<-.data.frame( *tmp*, "SHAPE_AREAS", value = c (652270.070308042 ,: replacement has 177 rows, data has 210
Disclaimer: I have already checked other answers, such as this or this and also this explanation , which says that usually this error comes from spelling objects, but cannot find the answer to my problem.
Playable Code:
library(rgdal)
library(dplyr)
library(tmap)
countries = readOGR(dsn = "https://gist.githubusercontent.com/ccamara/fc26d8bb7e777488b446fbaad1e6ea63/raw/a6f69b6c3b4a75b02858e966b9d36c85982cbd32/countries.geojson")
df = read.csv("https://gist.githubusercontent.com/ccamara/fc26d8bb7e777488b446fbaad1e6ea63/raw/754ea37e4aba1b7ed88eaebd2c75fd4afcc54c51/sample-dataframe.csv")
countries@data = left_join(countries@data, df, by = c("iso_a2" = "country_code"))
qtm(countries, "freq")
source
share