Remove objects that no longer used

Hi there,

Little by little my Rmd document gets bigger and bigger. I'm getting closer to the moment when my machine wouldn't have enough memory to knit it. I know that I keep quite a lot of objects that no longer used and it would be nice idea to get rid of them.
Is there any package/utility that can scan document and add remove('object_name') in the appropriate places (i.e. after last usage of the object)? Essentially, I want something similar to the {styler} that can do the dirty work))

I am not aware of such a tool but I believe also it should not be done by such a tool. A better approach is to refactor code into smaller functions that have one return value (and throw away all other values as soon as the function execution completes). Or use a dependency management tool such as {targets} to build intermediate outputs, which even has specific Rmd workflows (just search the web for it).

1 Like

@lorenzwalthert ,

Thank you for your kind suggestions. Perhaps, I have to implement a better coding practice)

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.