How to use R's `browser()` function from command line when using `Rscript`

StackOverflow https://stackoverflow.com/questions/18292602

  •  24-06-2022
  •  | 
  •  

Pregunta

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?

¿Fue útil?

Solución

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").

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top