How to work out which files are active in your project

I have a RMarkdown project that I have inherited. All of it is self contained within a folder. Over the years, people have added new files and left old ones in there and now there are 100s of files.
There are many R files that are linked to the Rmarkdown script and therefore difficult to go through them all.
Is there a script that I could run that goes through the RMarkdown script and lists all the active files being used by the project? That way I could know which files are in use and which arent?

Can you supply a more precise / technical description of what you mean by 'linked' ?

perhaps it source()'s the files ? or something else ?

G'day Basile:
I've been (and still I am) with this kind of issues when one inherits other's protocols, structures of folders etc...

With the information you provide (and keeping the solution inside R), I reckon I would load the document into R, probably with readLines, and then search for the lines that have some regular expressions like read.csv, readRDS, or anything like that, and see what is being read / imported along the script.

However, you mention hundreds of files, so there may be files loaded/called inside files that then are called in/loaded in subsequent scripts... a real mess.

Such a great mess.

In your case, I would do it by hand. Separating the Rmd file form the other files and in a clean environment sequentially run it and find out what's missing at each step. I don't say don't use R or anything "programming related", I say for me it would be faster to do that way (few hundreds of files = a long couple of hours?) vs many hours finding a solution inside R and making test to prove that it is working safely.

I'll keep an eye to see better solutions, as it interests me :slight_smile:

Yes ,I use source to call in the R files.

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.

The RMarkdown script calls other R files eg it will call an R file to produce a ggplot. It will call a different one to produce a table etc.