嘿,我一直在努力用我的数据集重新创建与此类似的图: https://twitter.com/thomasp85/status/1036915662025895936?lang=en
我无法用令人讨厌的reprex重现错误,但是错误消息是这样的:
sprintf(paste0(“%0”,nc,“ i”),frame)中的错误: 格式'%0NA'无效;对数字对象使用%f,%e,%g或%a格式
这是我以前从未处理过的错误,感谢您的帮助
df <- structure(list(long = c(23.9665031433105, 23.9665031433105, 23.9665031433105,
23.9665031433105, 23.9665031433105, 23.9665031433105), lat = c(-10.8717775344849,
-10.8717775344849, -10.8717775344849, -10.8717775344849, -10.8717775344849,
-10.8717775344849), group = c(3, 3, 3, 3, 3, 3), region = structure(c(2L,
2L, 2L, 2L, 2L, 2L), .Label = c("Algeria", "Angola", "Benin",
"Botswana", "Burkina Faso", "Burundi", "Cameroon", "Central African Republic",
"Chad", "Comoros", "Democratic Republic of the Congo", "Djibouti",
"Egypt", "Equatorial Guinea", "Eritrea", "Ethiopia", "Gabon",
"Gambia", "Ghana", "Guinea", "Guinea-Bissau", "Ivory Coast",
"Kenya", "Lesotho", "Liberia", "Libya", "Madagascar", "Malawi",
"Mali", "Mauritania", "Mauritius", "Morocco", "Mozambique", "Namibia",
"Niger", "Nigeria", "Republic of Congo", "Rwanda", "Senegal",
"Seychelles", "Sierra Leone", "Somalia", "South Africa", "South Sudan",
"Sudan", "Swaziland", "Tanzania", "Togo", "Tunisia", "Uganda",
"Zambia", "Zimbabwe"), class = "factor"), year = c(1970, 1971,
1972, 1973, 1974, 1975), rate = c(NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_), pop = c(31787566, 31787566, 31787566,
31787566, 31787566, 31787566), subregion = c("Middle Africa",
"Middle Africa", "Middle Africa", "Middle Africa", "Middle Africa",
"Middle Africa")), row.names = c(NA, 6L), class = "data.frame")
ggplot(df, aes(x = year, y = rate, group = region)) +
geom_line() + geom_segment(aes(xend = 2018, yend = rate)) +
geom_point() + transition_reveal(year) + ease_aes("linear")
#> Error in ggplot(uis_final_line, aes(x = year, y = rate, group = region)): could not find function "ggplot"
由reprex package(v0.2.1)于2019-01-23创建