c@buhtz m@iii@g oii posteo@jp
2021-Sep-21 07:12 UTC
[R] Windows: start script but keep being in R-shell after finish
Hello together, I was using R some years ago and I am sorry for asking such a dumb question. I found some help instructions about commandline interface but I still miss the piece of information I need. I assume it depends on my non-nativ English that I am not able to ask the correct (worded) question to the search engines. I use R-for-windows on the shell. No GUI, IDE or anything else. When I am in windows shell ("command prompt"?) I wan't to run an R-script (filename *.R). But when the script is finished or interrupted the R-prompt should do not close. In python I would do python3 -i -m myscript Kind Christian
Duncan Murdoch
2021-Sep-21 13:09 UTC
[R] Windows: start script but keep being in R-shell after finish
On 21/09/2021 3:12 a.m., c.buhtz at posteo.jp wrote:> Hello together, > > I was using R some years ago and I am sorry for asking such a dumb > question. I found some help instructions about commandline interface but > I still miss the piece of information I need. I assume it depends on my > non-nativ English that I am not able to ask the correct (worded) > question to the search engines. > > I use R-for-windows on the shell. No GUI, IDE or anything else. > When I am in windows shell ("command prompt"?) I wan't to run an > R-script (filename *.R). But when the script is finished or interrupted > the R-prompt should do not close. > > In python I would do > > python3 -i -m myscriptI don't think R supports this, but the following almost works: cat myscript.R - | Rterm --ess This copies your file followed by stdin into the stdin of R. The --ess option tells R to act as if input is interactive, despite what it sees. This comes kind of close, but there are a couple of problems. - If I type really fast, the characters appear in the wrong order in R. - At the end when I quit, it sits there for a while until I hit enter, then gives the error message "cat: write error: no more space on device". Perhaps these problems can be fixed. Another approach would be to set an environment variable specifying that myscript.R is a user profile file, set via environment variable R_PROFILE_USER=myscript.R This has the disadvantage of overriding a pre-existing user profile file, but if this is just for you, I guess you know if you have one. Duncan Murdoch