How can force close an open script file - or in general an open tab - in RStudio using code?
As pointed here I already know that file.edit('test.R')
can open a given file.
This is how I usually end a given script file before moving to an other section.
What I'd like to do, is to start the new section (script file) from closing what was used before.
For example:
import_data.R
has code that does all file reading / importing and when that's done, it opens data_wrangle.R
by calling file.edit("data_wrangle.R")
where all the transforming, mutating etc is done.
Since I don't need the import code any more, I'd like to close previous script (import_data.R
in this case) with a line of code.
I did some guesswork calling
close("./script/test.R")
or
rm("./script/test.R")
but they clearly don't serve this purpose.