I am new to R, so bear with me if I dont upload this question exactly by the standard way to do it.
I am trying to create an animated chart, where a cat's face is located on the head of the line in the chart, as the chart is playing/printing historical Bitcoin price. I use gganimate and ggcats. This animation is not my end goal, it is to see if this makes sense to use for another business idea.
First, below what works so far:
library(tidyverse)
library(gganimate)
library(ggcats)
library(hrbrthemes)
library(tidyquant)
library(PerformanceAnalytics)
library(gifski)
library(Rtools)
library(magrittr)
library(plotly)
library(Ecdat)
library(ggplot2)
library(dplyr)
library(rlang)`
Tiingo:
tiingo_api_key('Censured')
Bitcoin <- tq_get("btcusd", get = "tiingo.crypto", from = "2020-01-01", to = "2023-02-19",
resample_frequency = "5min")
transform dttm column to type Date:
Bitcoin$date <- as.Date(Bitcoin$date)
The animation:
bitcoin_anim_cat <- Bitcoin %>%
ggplot(aes(x = date, y = close)) +
geom_line(size = 2) +
geom_cat(aes(cat = "BTC price"), size = 4) + # I was hoping to use the cat_col, but something's
wonky
scale_x_date(date_breaks = "1 month", date_labels = "%b") +
scale_y_continuous(breaks = seq(3500,5000,100)) +
theme_ipsum_rc() +
labs(
title = sprintf("Bitcoin price development over time", symbol),
x = "Date",
y = "Closing Price",
caption = "http://tradervoice.io"
) +
transition_reveal(date)
PROBLEM:
When I run this line:
animate(bitcoin_anim_cat, duration = 10, fps = 20, width = 800, height = 800, renderer =
gifski_renderer())
I get this:
geom_line()
: Each group consists of only one observation.
i Do you need to adjust the group aesthetic?
geom_line()
: Each group consists of only one observation.
i Do you need to adjust the group aesthetic?
Inserting image 200 at 9.95s (100%)... Encoding to gif... done! There were 50 or more warnings (use warnings() to see the first 50)
Then I ran:
warnings()
And got:
Warning messages:
1: Cannot get dimensions of plot table. Plot region might not be fixed
2: Problem while converting geom to grob.
i Error occurred in the 2nd layer.
Caused by error in magick::image_read()
:
! path must be URL, filename or raw vector
3: Problem while converting geom to grob.
i Error occurred in the 2nd layer.
Caused by error in magick::image_read()
:
! path must be URL, filename or raw vector
4: Problem while converting geom to grob.
i Error occurred in the 2nd layer.
Which continues with "5:", "6:" etc...
I have tried to find solutions in here for similar problems but with no luck.