Warning message: file_renderer failed to copy frames to the destination directory

Hello,

As a newbie (1 week in to R) I'm trying to use the gganimate package on some data from gapminder. I've written/copied the following:

p <- ggplot(
  gapminder, 
  aes(x = gdpPercap, y=lifeExp, size = pop, colour = country)
) +
  geom_point(show.legend = FALSE, alpha = 0.7) +
  scale_color_viridis_d() +
  scale_size(range = c(2, 12)) +
  scale_x_log10() +
  labs(x = "GDP per capita", y = "Life expectancy")
p
p + transition_time(year) +
  labs(title = "Year: {frame_time}")

and when running I get the following warning message:

Warning message:
file_renderer failed to copy frames to the destination directory

As far as I'm aware I have the requisite rendering packages (gifski, png).

Any thoughts on how to get this to run?

Thanks,

Christian

1 Like

This looks like a write permissions issue, double-check that you have write permissions in your working directory or run RStudio as superuser (administrator rights).

1 Like

Many thanks...I will look at this now.

Hi. Let's put this in a reproducible example, called a reprex

library(gapminder)
library(ggplot2)
library(gganimate)
data(gapminder)
p <- ggplot(
gapminder,
aes(x = gdpPercap, y=lifeExp, size = pop, colour = country)
) +
geom_point(show.legend = FALSE, alpha = 0.7) +
scale_color_viridis_d() +
scale_size(range = c(2, 12)) +
scale_x_log10() +
labs(x = "GDP per capita", y = "Life expectancy")
p + transition_time(year)

Created on 2019-11-20 by the reprex package (v0.3.0)

What's missing is any code that invokes file_renderer, the source of the error. @andresrcs may well be right about permissions, but it would be good to post the exact code and see if it has any issues with the function signature:

file_renderer(dir = ".", prefix = "gganim_plot", overwrite = FALSE)

If that doesn't solve your problem and you are working on a .Rmd file, another possible cause could be that you can't embed gif animations into a .Rmd file and you would have to use ffmpeg renderer. to produce mp4 files instead.

1 Like

Thanks for the suggestions. So I ran this (just learnt about reprex - thank you):

p <- ggplot(
  gapminder, 
  aes(x = gdpPercap, y=lifeExp, size = pop, colour = country)
) +
  geom_point(show.legend = FALSE, alpha = 0.7) +
  scale_color_viridis_d() +
  scale_size(range = c(2, 12)) +
  scale_x_log10() +
  labs(x = "GDP per capita", y = "Life expectancy")
#> Error in ggplot(gapminder, aes(x = gdpPercap, y = lifeExp, size = pop, : could not find function "ggplot"
p
#> Error in eval(expr, envir, enclos): object 'p' not found
p + transition_time(year) +
  labs(title = "Year: {frame_time}")
#> Error in eval(expr, envir, enclos): object 'p' not found
file_renderer(dir = ".", prefix = "gganim_plot", overwrite = FALSE)
#> Error in file_renderer(dir = ".", prefix = "gganim_plot", overwrite = FALSE): could not find function "file_renderer"

Created on 2019-11-20 by the reprex package (v0.3.0)

And no joy. I get the following:
99 /var/folders/qk/n8zc5v7j06v13bzvvlmm2jxm0000gn/T//RtmpRRQzVz/48c95be18abc/gganim_plot0099.png
100 /var/folders/qk/n8zc5v7j06v13bzvvlmm2jxm0000gn/T//RtmpRRQzVz/48c95be18abc/gganim_plot0100.png
Warning message:
file_renderer failed to copy frames to the destination directory

file_renderer(dir = ".", prefix = "gganim_plot", overwrite = FALSE)
function (frames, fps)
{
if (!dir.exists(dir))
dir.create(dir, showWarnings = FALSE, recursive = TRUE)
new_names <- file.path(dir, sub("gganim_plot", prefix, basename(frames)))
if (any(!file.copy(frames, new_names, overwrite = overwrite))) {
warning("file_renderer failed to copy frames to the destination directory",
call. = FALSE)
}
invisible(new_names)
}
<bytecode: 0x7facfce74930>
<environment: 0x7face179b770>

Any clue? Apologies as I really can't overstate how green I am to all this! (I grew up with an abacus)

Christian

A side note about your reprex, you have forgot to include library calls, that is why you are getting those "could not find function" error messages.

1 Like

Oh goodness - what a steep learning curve!

1 Like

It's a hill we all climb! This is especially true for those like myself who come from a background with the procedural/imperative languages such as C and its progeny and Python. It finally became easier for me when I realized that R is school algebra writ large: f(x) = y, functions and objects, and some objects are arguments and others are results. {Thus endeth the sermon.}

I can tell that you are on MAC OS, because I am too:

 $ 508:  getconf DARWIN_USER_CACHE_DIR
/var/folders/vw/p54wdfm95lq9wf8jkwxg_qpw0000gp/C/
 $ 509:  getconf DARWIN_USER_CACHE_DIR  | ls -l
total 0
drwxr-xr-x@ 6 rc  staff   192B Feb 25  2019 p54wdfm95lq9wf8jkwxg_qpw0000gp/

My login name is rc and this is my cache file. I own it, I can read, write and execute anything in it.

So, the next step to confirm that you can do the same.

Good afternoon,

Yep you (and Anders) were right. It was a permission issue. Thank you so much for your help. I learnt quite a bit from this exercise, more than just how to fix the issue.

Best wishes,

Christian

1 Like

Great! For the benefit of future readers please mark a solution.

hi guys.
I have the same problem, I got this message, but how could you solve it? I do not really see that
Thank for your help in advance

1 Like

Hi Marcell,

It was indeed a rights permission. I had to go into /var/folders/ and set permission to read and write (it had defaulted to read only I think).

Try it and see.

Christian

okey, but my problem is that where did you do that? Is it within the R or I should use the file manager?

Sorry. Yes, file manager. I went to finder->mac HD->var->folders. Right click->getinfo, select permissions down the bottom.

Hope it works.

2 Likes

Okey, then one more problem. I use Windows :smiley: Do you know maybe how I should solve then?

Ah, not really! Sorry - I'm a complete newbie to all this. Maybe ask one of the guys above!

Sorry.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.