0

I have a Rmd file with 3 sections, a, b and c. I can run everything up till the end of section b just fine with an output html document generated.

However, when I get to the section c I encounter memory issues. I am able to run this 3rd section on it's own.

So, I added a line before section c in my script starts with rm(list=ls()). However, this doesn't solve the problem which is confusing since this section will run on it's own if there is no code beforehand.

I found a suggestion for .rs.restartR() over here but presumably restarting R will interupt my Rmd file being rendered.

Is there a prescribed approach here?

Some older SO posts mention calling gc() but that did not help.

If I can run sections a and b on their own and then section c on it's own, can I not somehow render the whole Rmd document, sections a through c by clearing memory before the code in section c runs?

Doug Fir
  • 19,971
  • 47
  • 169
  • 299
  • A workaround might be to first render PDFs section by section and [combine them](https://stackoverflow.com/a/45467602/6574038) later. – jay.sf Feb 09 '19 at 19:22
  • Thanks but I'm rendering this as html since it's being hosted by my webserver, so trying to complete in a oner. Thanks for the suggestion though – Doug Fir Feb 09 '19 at 19:38

0 Answers0