world <- map_data("world") |> select(!subregion) |> # world geo info
mutate(region=ifelse(region=="UK", "United Kingdom", region))
intbxo <- read_csv("data/intl_bxo.csv", show_col_types = F, skip=6) |> # import/tidy bxo
select(1,6) |>
rename("region" = "Area", "wknd_gross" = "Weekend Gross") |>
filter(!is.na(wknd_gross)) |>
mutate(wknd_gross = gsub("$", "", wknd_gross, fixed = T),
wknd_gross = gsub(",", "", wknd_gross, fixed = T) |> as.numeric())
world_bxo_data <- full_join(intbxo, world) |> # join datasets
filter(!is.na(wknd_gross))
world_bxo_data$continent = countrycode(sourcevar = world_bxo_data$region, # retrieve continents
origin = "country.name",
destination = "continent")
head(world_bxo_data, 3)# A tibble: 3 × 7
region wknd_gross long lat group order continent
<chr> <dbl> <dbl> <dbl> <dbl> <int> <chr>
1 China 7400000 111. 20.0 418 28698 Asia
2 China 7400000 111. 19.9 418 28699 Asia
3 China 7400000 111. 19.9 418 28700 Asia