Ошибка с animate: невозможно найти унаследованный метод для функции «animate» для подписи «gganim» ’ - PullRequest
0 голосов
/ 13 мая 2019

Я хочу сделать анимированный сюжет с gganimate.Когда я пытаюсь визуализировать анимацию, появляется следующее сообщение об ошибке:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘animate’ for signature ‘"gganim"’ 

Этот код я пытаюсь воспроизвести.Я использую R 3.6.0

library(gganimate)
library(magick)
library(dplyr)
library(animation)
library(tidyverse)
library(patchwork)
library(animation)
library(sp)
library(raster)
library(rgeos)
library(gifski)

REPD <- readr::read_tsv(RCurl::getURL("https://gist.githubusercontent.com/dr-harper/abc79ce4ec63644324aa2e6134ddf1ac/raw/49f8a5d6c5c41395af46428007048be7301b9f7b/REPD.csv"))

planning_summary <- read.table(text = "
'Status'                        'Status Summary'
'Application Approved'        'Approved'
'Application Refused'           'Refused/Abandoned'
'Application Submitted'       'Submitted'
'Application Withdrawn'       'Refused/Abandoned'
'Connection Applied For'        'Submitted'
'No Application Made'           'Refused/Abandoned'
'No Application'              'Required Approved'
'Abandoned'                   'Refused/Abandoned'
'Awaiting Construction'       'Approved'
'Decommissioned'                'Approved'
'Operational'                   'Approved'
'Planning Permission Expired'   'Approved'
'Under Construction'            'Approved'
", header = TRUE, stringsAsFactors = FALSE)


REPD <-
  REPD %>%
  merge(planning_summary, by.x = "Development Status (short)", by.y = "Status") %>%
  mutate(date = lubridate::dmy(`Planning Application Submitted`),
         year = lubridate::year(date),
         `Installed Capacity (MWelec)` = as.numeric(`Installed Capacity (MWelec)`))

# Obtener fronteras:

UK <-  raster::getData('GADM', country='GBR', level = 1) %>%
  sp::spTransform(CRSobj = CRS("+init=epsg:27700")) %>%
  gSimplify(tol=1000, topologyPreserve=TRUE) %>%
  fortify()


REPD_tech <- 
  REPD %>%
  filter(`Status.Summary` == "Approved")
# build GIF
p <- 
  ggplot() +
  geom_polygon(data=UK, aes(long, lat, group = group), fill = "#528076") +
  geom_point(data = REPD_tech, aes(x = `X-coordinate`, y = `Y-coordinate`, fill = `Technology Type`),
             size = 5, shape = 21, alpha = 0.7) +

  # gganimate parts
  transition_states(`Technology Type`, transition_length = 2, state_length = 20) +
  enter_fade() +
  exit_fade() +
  # Styling
  coord_equal(xlim = c(-75000, 825000), ylim = c(0, 1200000)) +
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        axis.text = element_blank(),
        axis.title = element_blank(),
        axis.ticks = element_blank(),
        panel.background = element_rect(fill = "grey99", colour = "grey80"),
        plot.title = element_text(hjust = 0, size = 16, vjust=0))
animate(p, length = 15, width = 700, height = 400)
...