1

The transition imageI am unable to get the facets for 3 years of provincial GDP of provinces of China. My data is as follows.

structure(list(Pr_mlnyn = structure(c(2L, 27L, 10L, 25L, 19L, 
18L, 17L, 11L, 24L, 15L, 31L, 1L, 4L, 16L, 23L, 12L, 13L, 14L, 
6L, 7L, 9L, 3L, 26L, 8L, 30L, 29L, 22L, 5L, 21L, 20L, 28L, 2L, 
27L, 10L, 25L, 19L, 18L, 17L, 11L, 24L, 15L, 31L, 1L, 4L, 16L, 
23L, 12L, 13L, 14L, 6L, 7L, 9L, 3L, 26L, 8L, 30L, 29L, 22L, 5L, 
21L, 20L, 28L, 2L, 27L, 10L, 25L, 19L, 18L, 17L, 11L, 24L, 15L, 
31L, 1L, 4L, 16L, 23L, 12L, 13L, 14L, 6L, 7L, 9L, 3L, 26L, 8L, 
30L, 29L, 22L, 5L, 21L, 20L, 28L), .Label = c("Anhui", "Beijing", 
"Chongqing", "Fujian", "Gansu", "Guangdong", "Guangxi", "Guizhou", 
"Hainan", "Hebei", "Heilongjiang", "Henan", "Hubei", "Hunan", 
"Jiangsu", "Jiangxi", "Jilin", "Liaoning", "Nei Mongol", "Ningxia Hui", 
"Qinghai", "Shaanxi", "Shandong", "Shanghai", "Shanxi", "Sichuan", 
"Tianjin", "Xinjiang Uygur", "Xizang", "Yunnan", "Zhejiang"), class = "factor"), 
    year = c(2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 
    2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 
    2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 
    2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2012L, 2012L, 2012L, 
    2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
    2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
    2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
    2012L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 
    2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 
    2017L, 2017L, 2017L, 2017L, 2017L), gdp = c(1111500L, 671901L, 
    1601197L, 731540L, 849620L, 1366858L, 642610L, 831437L, 1406986L, 
    3098198L, 2146269L, 885166L, 1082301L, 697105L, 3093328L, 
    1801853L, 1132892L, 1155500L, 3679671L, 702100L, 150306L, 
    579366L, 1260123L, 356156L, 569212L, 39485L, 731458L, 316682L, 
    101862L, 120392L, 418321L, 1787940L, 1289388L, 2657501L, 
    1211283L, 1588058L, 2484643L, 1193924L, 1369158L, 2018172L, 
    5405822L, 3466533L, 1721205L, 1970178L, 1294888L, 5001324L, 
    2959931L, 2225045L, 2215423L, 5706792L, 1303510L, 285554L, 
    1140960L, 2387280L, 685220L, 1030947L, 70103L, 1445368L, 
    565020L, 189354L, 234129L, 750531L, 2800035L, 1859538L, 3596400L, 
    1497351L, 1610317L, 2394200L, 1528894L, 1619988L, 3013386L, 
    8590094L, 5176826L, 2751867L, 3229828L, 2081850L, 7267818L, 
    4498816L, 3652295L, 3459056L, 8987923L, 2039625L, 446254L, 
    1950027L, 3698022L, 1354083L, 1653134L, 131063L, 2189881L, 
    767700L, 264280L, 345393L, 1092009L)), row.names = c(NA, 
-93L), class = "data.frame")

I inserted columns from data.frame to the spatial object as follows cn4 <- left_join(cn3, cg2, by = c("Prov" = "Pr_mlnyn")) and after that I ran this code.

q <- tm_shape(cn4, bbox = bb_cn) +
  tm_polygons(col = "gdp") +
  tm_facets(along = "year", free.coords = FALSE)

tmap_animation(q, filename = "cnprgdp.gif", delay = 100)

But, as you can see the animation is not correct for 2008 and 2012.

  • What happens if you do each of the parts of the summation separately, e.g. just do tm_shape(cn3, bbox = bb_cn), and see if it comes up with an error, then repeat for the other 4 parts? – smiller Dec 26 '18 at 4:45

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.