0% found this document useful (0 votes)
3 views

Creating plotly maps in R

The document contains R code that utilizes the Plotly library to visualize data on life expectancy, GDP, and population across different continents. It includes three main visualizations: mean life expectancy in Asian countries, GDP deviation in European and selected South American countries, and population changes in African countries over the last three decades. The data is sourced from a CSV file containing country statistics.

Uploaded by

modem40203
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Creating plotly maps in R

The document contains R code that utilizes the Plotly library to visualize data on life expectancy, GDP, and population across different continents. It includes three main visualizations: mean life expectancy in Asian countries, GDP deviation in European and selected South American countries, and population changes in African countries over the last three decades. The data is sourced from a CSV file containing country statistics.

Uploaded by

modem40203
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

#imports

library('plotly')

#data

countries <- read.csv('C:/Users/hp/Documents/countries.csv',header=TRUE)

#question 1 avarage life expectancy Asia

Asia<- countries %>% filter(continent=="Asia")

lifeEXp <- Asia %>% group_by(country,iso_alpha)%>% summarise(meanLifeEXp=mean(lifeExp),.groups =


'drop')

fig <- plot_ly(lifeEXp,

type='choropleth',

locations=lifeEXp$iso_alpha,

z=lifeEXp$meanLifeEXp,

text=lifeEXp$country)%>%

layout(title = "Mean Life Expectancy in Asian Countries")

fig

#question 2 deviation of gdp in European countries

Europe<- countries %>% filter(continent=="Europe")

SAmerica <- countries %>% filter(country=='Paraguay'|country== 'Brazil' | country=='Uruguay'

| country=='Argentina' | country=='Bolivia'| country=='Chile' |

country=='Colombia' | country=='Venezuela'| country=='Peru' |


country=='Ecuador')

EuroAmerica <- rbind(SAmerica,Europe)

fig <- plot_ly(EuroAmerica,

type='choropleth',

locations=EuroAmerica$iso_alpha,

z=EuroAmerica$gdpPercap,

text=EuroAmerica$country,

frame = EuroAmerica$year)%>%

layout(title="Deviation of GDPin Europe and South American countries")

fig

#question 3 change of population in african countries last three decades

Africa<- countries %>% filter(continent=="Africa")

fig <- plot_ly(Africa,

type='choropleth',

locations=Africa$iso_alpha,

z=Africa$pop,

text=Africa$country,

frame = Africa$year)%>%

layout(title="Deviation of population in Africa in the last 3 decades")

fig

You might also like