suppressWarnings(library(plotly))
economyRanking<-read.csv("Economy Rankings2.csv")
#economyRanking<-read.csv("Economy Rankings.csv", header= TRUE,sep=",",na.strings = "?",stringsAsFactors=FALSE)
#head(economyRanking,3)

economyRanking<-subset(economyRanking, select=c("code","Economy", "Ease.of.Doing.Business.Rank"))

colnames(economyRanking)[3] <- "Rank"

l <- list(color = toRGB("grey"), width = 0.5)
g <- list(
  showframe = FALSE,
  showcoastlines = FALSE,
  projection = list(type = 'Mercator')
)

p <- plot_geo(economyRanking) %>%
    add_trace(
        z = ~Rank, color = ~Rank, 
        text = ~Economy, locations = ~code, marker = list(line = l)
    ) %>%
    
    layout(
        title = 'Ease of doing business Ranking',
        geo = g
    )
p
########Bubble#####
yearWiseRanking<-economyRanking<-read.csv("distance-to-frontier.csv",na.strings = "?",stringsAsFactors=FALSE)
head(yearWiseRanking)
##                                 Economy DB.2010 DB.2011 DB.2012 DB.2013
## 1           United States - Los Angeles      NA      NA      NA      NA
## 2                    Mexico - Monterrey      NA      NA      NA      NA
## 3                         Japan - Osaka      NA      NA      NA      NA
## 4 Russian Federation - Saint Petersburg      NA      NA      NA      NA
## 5                                 Malta      NA      NA    62.1   62.05
## 6                            San Marino      NA      NA      NA   63.81
##   DB.2014 DB.2015 DB.2016 DB.2017       X
## 1   78.56   80.68   80.96   80.96 #VALUE!
## 2   71.24   75.20   75.73   75.93 #VALUE!
## 3   77.13   75.06   75.27   75.44 #VALUE!
## 4   66.51   70.92   72.83   72.94 #VALUE!
## 5   62.34   63.84   62.52   65.01 #VALUE!
## 6   63.00   62.67   63.55   64.11 #VALUE!
#head<-head(yearWiseRanking)
head<-subset(yearWiseRanking, Economy=='India' | Economy=='Ukraine')
library(dplyr)
library(tidyr)



head<-subset(yearWiseRanking,  Economy=='Russia' |Economy=='Ukraine'|Economy=='Yemen')
head1<-gather(head, "Year", "scoreOutOf100", 4:8)
p <- plot_ly(head1, x = ~Year, y = ~Economy, text = ~scoreOutOf100, type = 'scatter', mode = 'markers', color = ~scoreOutOf100, 
             marker = list(size = ~scoreOutOf100, opacity = 0.5)) %>%
    layout(title = 'Significant changes of countries over time',
           xaxis = list(showgrid = FALSE),
           yaxis = list(showgrid = FALSE))

p