Hey y'all, need your help figuring this one out. I managed to construct a data table in R which listed all 176 of my PNG outmap maps by filename, year, month, and day considering they were labeled as such, "Avg_monthly_2005_06_01.png" as an example. I can filter the data table to spit out only desired years such as 2006 or 2010, however, I am struggling at the next step of creating a GIF from those specific PNGs.
One fellow RStudio person recommended using file.copy() by calling the filename column of my data column and moving specific years (let us say only the 2006 PNG output maps) into a specific folder. From there, it is easy enough to construct a GIF. Does anyone know how to code this? I am stuck on trying to find a way to write a line of code that can let me use the filename column of my data table to call file.copy() and move those files into another folder in my working directory.
Here is my code below if that helps:
file_list <- list.files("C:/Users/Documents/gifmonthlybarca/barca_monthly")
file_list
dataframe <- tibble(my_filenames = file_list) %>%
mutate(fields = strsplit(file_list, "_"),
date_fields = map(fields, ~ .x[(length(.x)-2): length(.x)]),
year = map_chr(date_fields, ~ .x[1]),
month = map_chr(date_fields, ~ .x[2]),
day = map_chr(date_fields, ~ .x[3]),
year = as.integer(year),
month = as.integer(month),
day = as.integer(day)) %>%
select(my_filenames, year:day)
barca_2006 <- filter(dataframe, year == "2006")