I need to find the difference between '2016' and '2018' but it doesn't work. Because I cannot reach the website so I downloaded it. You may work with it as I put the original data at the top.
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
energy_types <- read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-08-04/energy_types.csv")
#> Error in open.connection(structure(4L, class = c("curl", "connection"), conn_id = <pointer: 0x000000000000024b>), : Could not resolve host: raw.githubusercontent.com
country_totals <- read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-08-04/country_totals.csv")
#> Error in open.connection(structure(5L, class = c("curl", "connection"), conn_id = <pointer: 0x000000000000024d>), : Could not resolve host: raw.githubusercontent.com
energy_types_filter <- energy_types %>%
filter(type == "Conventional thermal")
#> Error in filter(., type == "Conventional thermal"): 找不到对象'energy_types'
energy_types_filter %>%
mutate(change = diff('2016', '2018'))
#> Error in mutate(., change = diff("2016", "2018")): 找不到对象'energy_types_filter'
arrange(energy_types_filter, desc(change))
#> Error in arrange(energy_types_filter, desc(change)): 找不到对象'energy_types_filter'
mutate(energy_types_filter, country_name = fct_inorder(country_name))
#> Error in mutate(energy_types_filter, country_name = fct_inorder(country_name)): 找不到对象'energy_types_filter'
gg_energy_types_filter <- ggplot(
energy_types_filter,
aes(x = 0, xend = change, y = country_name, yend = country_name), color = "blue"
) +
geom_segment(arrow = grid::arrow(length = unit(1, "mm"), type = "closed"), color = 0.9) +
theme(axis.title.y = element_blank()) +
geom_text(color = c("firebrick", "steelblue"))
#> Error in ggplot(energy_types_filter, aes(x = 0, xend = change, y = country_name, : 找不到对象'energy_types_filter'
theme_minimal_vgrid() +
theme(legend = element_blank())
#> Error in theme_minimal_vgrid(): 没有"theme_minimal_vgrid"这个函数