Как использовать gganimate для символа оси X - PullRequest
0 голосов
/ 13 марта 2020

У меня есть следующие данные:

df <- structure(list(Date = structure(c(5L, 6L, 7L, 8L, 9L, 10L, 11L, 
1L, 2L, 3L, 4L), .Label = c("01-Apr", "02-Apr", "03-Apr", "04-Apr", 
"25-Mar", "26-Mar", "27-Mar", "28-Mar", "29-Mar", "30-Mar", "31-Mar"
), class = "factor"), New = c(2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
9L, 0L, 6L)), class = "data.frame", row.names = c(NA, -11L))

Это мой текущий код:

df$Date<-as.character(df$Date)
df$Date <- factor(df$Date, levels=unique(df$Date))

p <- ggplot(data=df, aes(x=Date, y=New, group=1)) + 
        geom_line() + 
        theme_classic() + 
        theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
        xlab("Date") +ylab("Total")+theme(axis.text.x=element_text(size=5))

Я хочу использовать gganimate для анимации графика, но когда я использую код

p+transition_reveal(Date)

Я получаю ошибку

Error: along data must either be integer, numeric, POSIXct, Date, difftime, orhms
In addition: Warning message:
In min(cl[cl != 0]) : no non-missing arguments to min; returning Inf

Предложения?

Попытка создать что-то вроде сюжетов geom_line из https://www.datanovia.com/en/blog/gganimate-how-to-create-plots-with-beautiful-animation-in-r/

...