Search code examples
rstudio

How to open multiple R scripts at once?


I am trying to a shortcut such that I can open all the r scripts in a file at once without clicking multiple times of open files.

enter image description here

I have already tried find in files but it cannot read all the files at once... Please give me some suggestions, thank you!


Solution

  • You can iterate over a vector of file names calling rstudioapi::documentOpen(). For example, to open all files with a .R extension in the working directory:

    lapply(list.files(pattern = "\\.R$"), rstudioapi::documentOpen)