rhighchartsrworldmap

World Map Using Highchart in R


I am analyzing the covid data from Kaggle. I am trying to plot world map with different scenarios such as total cases, new cases, total vaccinated etc.

Am using this syntax:

covid<-fread(covid_data.csv)

I have renamed the column name 'location' to 'region' for joining with other world map data.

country_count<-covid %>% 
  group_by(region, total_cases, iso_code) %>% 
  summarise(count=n()) %>% 
  as.data.frame
  
highchart() %>%
  hc_add_series_map(worldgeojson, df = country_count, value = "total_cases", joinBy = "iso_code") %>% 
  hc_legend(enabled = TRUE) %>% 
  hc_add_theme(hc_theme_db()) %>% 
  hc_mapNavigation(enabled = TRUE) %>%
  hc_title(text = "Total Cases", style = list(fontSize = "25px")) %>%
  hc_add_theme(hc_theme_google()) %>%
  hc_credits(enabled = TRUE,text = "Sources: WHO", style = list(fontSize = "10px"))

The map is populating very slowly and I want to fill the world map with color hue based on the number of total cases. But am not sure how to populate this using hc_colorAxis.

Can someone please suggest how to achieve this.

Any tweaks that could load maps faster is appreciated. Thank you


Solution

  • I was doing the wrong way. Instead of iso_code, I should join by name. This fixed the issue.