Shashivydyula
Shashivydyula

Reputation: 85

Convert Numbers to Millions/Thousands in R Highchart World Map

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

Upvotes: 1

Views: 55

Answers (0)

Related Questions