I would like to have a mode where I can run some R code in an executable script, like with Rscript, but interactively, so that e.g. 'browser()' works. From the manual page it looks like this should work: R --interactive -e 'source("script.R")' or we could shorten it to: R --interactive -e 'browser()' However, it seems that --interactive causes -e to be ignored. And if I leave out --interactive, then R quits before the browser() function exits. From an engineering standpoint it doesn't seem like it should be very difficult to tell the interactive REPL to pretend that a certain command was entered before everything else. Also, it would be useful to me to be able to debug R scripts using standard features like 'browser()'. Should I submit a feature request on Bugzilla, or maybe someone can advise me how to proceed? Thanks, Frederick
Here's what I would expect: In interactive mode, input is taken from the user (i.e. command line). In non-interactive mode, input is taken from a text file (or equivalent). What you're trying to do is run R in *non*-interactive mode, and call the browser function. This requires input to come from the user (i.e. command line) and from a text file (or equivalent), at essentially the same time. While doing fantasmoswankyblastik things with I/O is a lot of fun. I don't think it's R's job to do that. On Fri, Feb 21, 2020 at 6:25 PM <frederik at ofb.net> wrote:> > I would like to have a mode where I can run some R code in an executable script, like with Rscript, but interactively, so that e.g. 'browser()' works. > > From the manual page it looks like this should work: > > R --interactive -e 'source("script.R")' > > or we could shorten it to: > > R --interactive -e 'browser()' > > However, it seems that --interactive causes -e to be ignored. > > And if I leave out --interactive, then R quits before the browser() function exits. > > From an engineering standpoint it doesn't seem like it should be very difficult to tell the interactive REPL to pretend that a certain command was entered before everything else. Also, it would be useful to me to be able to debug R scripts using standard features like 'browser()'. Should I submit a feature request on Bugzilla, or maybe someone can advise me how to proceed? > > Thanks, > > Frederick > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
I should add: In theory, R could emulate the behavior of a compiled programming language. (In which case, R could read input from the user, or use debugging tools, when told to). However, I can't see R-core supporting this approach in the foreseeable future. A related topic is running R inside Java and C++ programs. Something R-core is *un*enthusiastic about...??? I note that a number of people have requested the ability to run R scripts like executable files (easily), or to run scripts with partial interactivity. It would be possible to create a special-purpose pty-based (or pty-like) application specifically to run R, which could allow the user to emulate the behavior of a compiled language (and do a few other things), but I'm wondering if it's ethical to publish it...??? On Sun, Feb 23, 2020 at 10:21 AM Abby Spurdle <spurdle.a at gmail.com> wrote:> > Here's what I would expect: > > In interactive mode, input is taken from the user (i.e. command line). > In non-interactive mode, input is taken from a text file (or equivalent). > > What you're trying to do is run R in *non*-interactive mode, and call > the browser function. > This requires input to come from the user (i.e. command line) and from > a text file (or equivalent), at essentially the same time. > > While doing fantasmoswankyblastik things with I/O is a lot of fun. > I don't think it's R's job to do that. > > > On Fri, Feb 21, 2020 at 6:25 PM <frederik at ofb.net> wrote: > > > > I would like to have a mode where I can run some R code in an executable script, like with Rscript, but interactively, so that e.g. 'browser()' works. > > > > From the manual page it looks like this should work: > > > > R --interactive -e 'source("script.R")' > > > > or we could shorten it to: > > > > R --interactive -e 'browser()' > > > > However, it seems that --interactive causes -e to be ignored. > > > > And if I leave out --interactive, then R quits before the browser() function exits. > > > > From an engineering standpoint it doesn't seem like it should be very difficult to tell the interactive REPL to pretend that a certain command was entered before everything else. Also, it would be useful to me to be able to debug R scripts using standard features like 'browser()'. Should I submit a feature request on Bugzilla, or maybe someone can advise me how to proceed? > > > > Thanks, > > > > Frederick > > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel
Maybe Matching Threads
- R --interactive -e 'browser()'
- problem submitting R bug; bug plotting in tiling window manager
- why does parent.frame() cycle when called from inside capture.output()?
- why does parent.frame() cycle when called from inside capture.output()?
- problem submitting R bug; bug plotting in tiling window manager