1

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.

I renamed location column name to name to join with worldgeojson.

Then filtered out total cases of all countries with the below syntax:

total_cases<-covid %>%
  select(name, date,total_cases) %>% 
  filter(name!='World',name!='Asia',name!='High income', 
         name!='Europe', name!='European Union', name!='Upper middle income',
         name!='North America', name!='Africa', name!='South America',
         name!='Lower middle income')

total_cases_world<-total_cases %>% 
  filter(date==max(date))

Am using this syntax to plot world map:

highchart() %>%
  hc_add_series_map(worldgeojson, df = total_cases_world, value = "total_cases", joinBy = "name") %>% 
  hc_legend(enabled = TRUE) %>% 
  hc_add_theme(hc_theme_bloom()) %>% 
  hc_colorAxis(minColor = "lightblue", maxColor="mediumblue") %>% 
  hc_mapNavigation(enabled = TRUE) %>%
  hc_title(text = "World Total Cases", style = list(fontSize = "25px")) %>%
  hc_subtitle(text="Total Covid Cases: 1.18 Billion", style=list(fontsize = "15px")) %>% 
  hc_add_theme(hc_theme_economist())

How to make the numbers in world map convert to millions/thousands instead of showing full numerical value? For example, I want the cases of USA to populate as 101 Million on map instead of 101,958,858.

World Map

  • In the related SO [topic](https://stackoverflow.com/questions/57886804/highcharts-r-show-tooltip-values-in-million-billion-etc-automatically) it's explained how to use `tooltip.formatter` and implement changing value format showing in the tooltip. – Sebastian Hajdus Jan 24 '23 at 09:22
  • I tried this but am getting error (sometimes the map populates without any numbers, sometimes the plot wont come up). Excuse me for my limited knowledge. Is it possible for you to show the snippet inserted into my above query, so that I can back track it. – Shashivydyula Jan 24 '23 at 11:58
  • Does the formatter in R work for you to inject JavaScript code into it? – Sebastian Hajdus Jan 24 '23 at 12:46
  • Yes it does. I am using R studio for desktop. – Shashivydyula Jan 24 '23 at 13:50

0 Answers0