I have a simple script file called test.R. It's saved in the working directory. When I go to File > Open > test.R, it opens the file in the editor (without executing the code, which is what I want).
How do I do this by typing a command in the console window? To be clear, I just want to open (not execute) the file.
The easiest way to do that is from within RStudio. Open a simple text file called an R script file by choosing the New File icon at the top-left, then choose R Script. RStudio can copy R commands from this text file and insert them into the R console as if you were manually entering commands yourself directly into R.
In addition, in Rstudio you can run the entire script by pressing Ctrl + Shift + Enter without selecting any code. In addition, there is a shortcut to source the current script file ( Ctrl + Shift + s ), which runs the script without echoing each line.
If R has been installed properly, simply entering R on the command line of a terminal should start the program. In Windows, the program is typically specified as the action performed when clicking on an icon. You can also use this method on a *NIX system that has a window manager such as KDE.
You are looking for file.edit
file.edit('test.R') should open the file in an editor (if you are in RStudio, this should default to RStudio)
It appears that if you are using RStudio then another option is to use rstudioapi::navigateToFile("test.R")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With