I'm having trouble creating a map with growing and squeezed bubbles with ggplotly. I have never used a plot before, so there may be an obvious solution to this. I really don't need to try to describe the problem more than just show you what the problem is. This is pretty obvious. This link gives you the following interactive map.

As you can see, the bubbles grow and shrink beautifully, but the problem is that every second year the bubbles appear behind the polygon. This is the only problem when the years earned work perfectly.
And here is the code you have to copy and run. Please note that I use geocodesggpmap from the package to load coordinates for each country. There is a limit of 2500 free downloads per day.
library(ggplot2)
library(plotly)
library(wbstats)
library(countrycode)
library(ggmap)
startdate = 2010
enddate = 2016
indicator <- "SM.POP.REFG"
dat <- wb(indicator = indicator,
startdate = startdate,
enddate = enddate)
worlds <- map_data("world")
worlds$iso2c = countrycode(worlds$region,
origin = "country.name",
destination = "iso2c")
merged <- merge(worlds, subset(dat, date==2016), sort=F, by="iso2c")
merged <- merged[order(merged$order), ]
cords <- geocode((unique(merged$country)))
cords <- data.frame(unique(merged$iso2c),unique(merged$country),cords)
colnames(cords) <- c("iso2c","country","lon","lat")
valuestocords <- unique(dat[,c("value","country","date")])
newdata = merge(cords, valuestocords, by = "country")
g <- ggplot(merged, aes(long, lat))+
geom_polygon(aes(group = group), fill="grey")+
geom_point(data=newdata, aes(lon, lat, size=value, ids=country, frame=date), alpha=0.5)+
scale_size_area()
ggplotly(g)