I'm attempting to create a series of gifs with different overlay text. Later I will merge the gifs together to create an animation where the overlay text changes at different intervals. I have tried to vectorize my for loop unsuccessfully using lapply and map. I think the issue may be that image_annotate() only accepts a vectorized input for the text parameter and not the image parameter. Does anyone have suggestions of how I might be able to successfully vectorize the for loop? TIA.
library(tidyverse)
library(magick)
elm <- matrix(nrow=26, ncol=7)
niagara <- rep(list(elm),250)
images <- seq(1,250)
overlay <- seq(2,500,2)
falls_gif <- image_read('https://media.giphy.com/media/jpxjacGJcdies/giphy.gif')
for (i in images){
niagara[[i]] <- falls_gif
niagara[[i]] <- niagara[[i]] %>%
image_annotate(paste0("Acre-Feet: ", overlay[i]))
}