How do I run a script with browser()
in it from the command line in such a way that it halt's execution?
Rscript file.R
Does not work for me. It seems I can only use browser()
from R
's interpreter. What am I doing wrong?
Starting R 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.
Use Rscript to run R from bash You can run it using Rscript test. r . And even better, if you add an initial shebang line #!/usr/bin/env Rscript in the script above and make it executable with chmod +x test. r , you can directly launch your R script with ./test.
R functions such as browser()
, debugger()
, or recover()
only work interactively.
If your script does not take command-line arguments a simple workaround is to start R and source("myscript.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