25th of April, 2019
First, we have to get the packages ggplot2 and plotly:
library(ggplot2)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
The dataset can be found here
And finally we can create the plot:
setwd("C:/Users/maxim/Desktop")
new_data <- read.csv("data.csv")
graph <- plot_ly(data=subset(new_data,Sex != "Total"), x = ~Country, y = ~Value, color=~Sex, type="bar") %>% layout(title="Population vs. Country regarding Gender in 2015", xaxis=list(title="Country", yaxis=list(title="Population")))
graph
## Warning: Ignoring 530 observations