[英]R ggplot2: How to connect points with arrows in Cartesian coordinates?
[英]How to connect points in datatable between them in R using ggplot2?
我从该站点获取了二氧化碳排放量的数据
重塑
df_reshaped <- data.frame(Countries = df$Country,
CO2 = c(df$X2018, df$X2017, df$X2016),
year = c(rep("X2018", nrow(newdf)),
rep("X2017", nrow(newdf)),
rep("X2016", nrow(newdf))))
# head(df_reshaped)
Countries CO2 year
1 China 9663.36 X2018
2 United States 4749.57 X2018
3 European Union (27) 2636.99 X2018
4 India 2400.25 X2018
5 Indonesia 1269.55 X2018
6 Japan 1074.08 X2018
如果我尝试可视化数据
ggplot(df_reshaped, aes(year, CO2, group=1, col = Countries)) + geom_point() + geom_line()
我需要以正确的方式连接每个国家/地区。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.