Programatically load file into Rstudio

Asked by At

I'm developing R code whose output is an R script, is it possible to automatically load the generated file in a RStudio tab?

So far I've checked the rstudioapi, but I don't find any suitable function.

Thanks in advance for any help.

PS: I've already tried:,".r"))

but open the file using an external editor.

1 Answers

Community On Best Solutions

You can use source("path/to/script.R") to run an R script, and load all the data/variables into the global R environment

In order to just open the file in RStudio, without running it, you can use rstudioapi::navigateToFile("path/to/file.R")