Hello! I was able to make your code work by changing Country to Codes and location to locations. I added some dummy data so you can see the slider work.
library(tibble)
library(plotly)
library(ggplot2)
Co2_Country_Graph3 <-
tibble::tribble(
~Country, ~Year, ~Co2_Emissions, ~Codes,
"China", 1990L, 2874L, "CHN",
"United States", 1990L, 5543L, "USA",
"India", 1990L, 1009L, "IND",
"Russia", 1990L, 2885L, "ROU",
"Indonesia", 1990L, 1257L, "IDN",
"Brazil", 1990L, 1642L, "BRA",
"China", 1991L, 2267L, "CHN",
"United States", 1991L, 4506L, "USA",
"India", 1991L, 4211L, "IND",
"Russia", 1991L, 4742L, "ROU",
"Indonesia", 1991L, 2278L, "IDN",
"Brazil", 1991L, 4860L, "BRA"
)
Co2_Country_Graph4 <-
plot_geo(Co2_Country_Graph3,
locationmode = "country",
frame = ~ Year) %>%
add_trace(
locations = ~ Codes,
z = ~ Co2_Emissions,
reversescale = T,
color = ~ Co2_Emissions
) %>%
layout(geo = list(showcountries = TRUE, scope = 'world'))
Co2_Country_Graph4