I know how to start R from the command-line and execute an expression (e.g., R -e 'print("hello")'
) or take input from a file (e.g., R -f filename.r
). However, in both cases, R runs the expression or commands in the file and then exits.
To quit R you can either use the RStudio > Quit pull-down menu command or execute ⌘ + Q (OS X) or ctrl + Q (PC).
Use the commandArgs() Function to Retrieve Arguments in R Arguments passed on the command line should be retrieved using the commandArgs() function. We will use it with the argument trailingOnly=TRUE . The function returns a character vector.
Use'SHIFT-ENTER' to get to a new line in R without executing the command.
In the terminal, the “normal” way is Control + C – the “cancel” key combination. In the graphical R application and in RStudio, it's Escape .
Put your script in a file called .Rprofile in the current directory. Then start R normally.
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