I was curious to see if there is an example somewhere of an R terminal exposed from Shiny (a basic command line interface exposed on a web page). Unfortunately the search terms for this on Google are not giving the results I want.
I would be very surprised that nobody tried to implement this and I don't want to re-invent the wheel.
It is fairly straightforward to implement something like this with system2. You could go as far as you want here, really, if you want to make the command-line experience better... I just wanted a simple terminal for exploration:
I'll work on exposing the code on GitHub. The only real way to see what I did at present is by executing cat app.R. I'm basically just splitting the command into cmd and args and passing it to system2 when the user clicks Run!.
Worth noting that this is a bad idea from a security perspective because it allows your users to execute arbitrary code on your operating system without any sanity checking from you. (I.e. they could spawn a run-away forking process and fill up your server). Perhaps useful from an educational perspective, though I leave the security and implementation to you!
EDIT: Also note - I installed the odbc package for no real reason relative to your question learnr would be the better example to walk users through a training session where they had a terminal / access to running R code.
If interested, the code is now available at https://github.com/colearendt/shiny-shell . I am glad that my random musings turned out to be helpful for you! Remember to stay safe/secure!
I noticed in your title that you may have been asking for an R terminal? If that is the case, you could use the same approach and just execute the R code instead of a system command. rlang has some helpful tools for this... maybe something like: