world_population <- read.csv(file="C:/Users/hp-pc/Desktop/Data_visualisation/Assignment_1/world-pop-by-political-regime_final.csv", header=TRUE, sep=",");
library(reshape)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:reshape':
##
## rename
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(gapminder)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:reshape':
##
## rename
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(devtools)
names(world_population)[4]<-"No Data"
names(world_population)[5]<-"Colony"
names(world_population)[6]<-"Autocracy"
names(world_population)[7]<-"Closed Anocracy"
names(world_population)[8]<-"Open Anocracy"
names(world_population)[9]<-"Democracy"
df <- as.data.frame(world_population);
df_melt <- melt(df, id.vars = "Year", measure.vars = c("No Data","Colony", "Autocracy", "Closed Anocracy","Open Anocracy","Democracy"));
names(df_melt)[3]<-paste("Population in million");
names(df_melt)[2]<-paste("political regimes");
p1 <- ggplot(df_melt) + geom_line(aes(x=Year, y=`Population in million`, color=`political regimes`),size=0.8) + facet_wrap( ~ `political regimes`, scales="free")+ggtitle("world population living under different political regimes(s3639703)") +
theme(plot.title = element_text(hjust = 0.5))
p1

gg1 <- ggplotly(p1)
gg1