你如何从R的Jaime Albella再现这张图表?
在visualcapitalist.com或twitter上查看动画(如果有一个中断,请提供几个参考).
我将其标记为ggplot2,gganimate但是可以从R生成的任何内容都是相关的.
数据(感谢https://github.com/datasets/gdp)
gdp <- read.csv("https://raw.github.com/datasets/gdp/master/data/gdp.csv")
# remove irrelevant aggregated values
words <- scan(
text="world income only total dividend asia euro america africa oecd",
what= character())
pattern <- paste0("(",words,")",collapse="|")
gdp <- subset(gdp, !grepl(pattern, Country.Name , ignore.case = TRUE))
Run Code Online (Sandbox Code Playgroud) 我试图按照下面的方法用 R 创建一个条形图竞赛。当我尝试将它们另存为 gif 文件时,所有 png 都会被创建,然后我得到:
Error: The animation object does not specify a save_animation method
Run Code Online (Sandbox Code Playgroud)
是否因为我创建了多个文件而发生这种情况?
#This script contains a function to produce a "bar chart race" in R
#The following links were invaluable:
#https://www.blakeshaffer.ca/post/making-animated-charts-with-gganimate/
#/sf/ask/3683660571/
#load required packages:
library(tidyverse)
library(gganimate)
#inputs:
#data - the dataset, must contain a column called "year"
#x - the column which contains the numeric value to plot
#y - the column which contains the labels of the plot
#optional:
#title - title …Run Code Online (Sandbox Code Playgroud)