world_population <- read.csv(file = "world_population.csv", header = TRUE, sep = ",")
countries <- read.csv(file = "countries.csv", header = TRUE, sep = ",")
countries <- countries[,c("Country","Latitude","Longitude")]
countries2 <- merge(countries, world_population, by.x = "Country", by.y = "Country.Other")
countries2 <- arrange(countries2, desc(Population..2020.))
top20 <- countries2[1:20, c("Country","Population..2020.","Med..Age")]
top20$Ranking <- seq(1:nrow(top20))
We see the Top 20 countries with more population:
fig <- plot_ly(top20, x = ~Ranking, y = ~Population..2020., text = ~Country,
type = 'bar',
marker = list(color = 'blue', line = list(color = 'pink', width = 1.5)))
fig <- fig %>% layout(title = '20 countries with more population in the world',
xaxis = list(showgrid = FALSE),
yaxis = list(showgrid = FALSE))
fig