Is it possible to attach to an already running R session?
Sometimes I need to kill RStudio / restart my R session and I would like to be able to reattach NeoVim to a new session without having to restart NeoVim also.
Is this possible? Apologies if it's documented somewhere, I did try to RTFM :sweat_smile:
(also happy to do a bit of hacking if you can point me in the right direction)
How are you using Neovim and RStudio? Are you using Nvim-R to start RStudio from Neovim? Is it possible to embed Neovim into RStudio?
How are you using Neovim and RStudio? Are you using Nvim-R to start RStudio from Neovim?
Yeah I am using Nvim-R to start RStudio with <Leader>rf.
That works great until I accidentally try to manipulate a dataset which is too big/too much for R/RStudio and it locks up. So at that point I need to kill and restart RStudio. But that breaks the link between RStudio and Nvim-R and it seems I can't start a new RStudio with Nvim-R without restarting Neovim.
I'm not sure how Nvim-R actually works, so please forgive my ignorance, but if I could do something like below that would be great:
- Start RStudio
- Start Neovim
- Connect Nvim-R to the running RStudio [1]
- Kill RStudio
- Start RStudio
- Connect Nvim-R to the newly started RStudio [1]
- If I had to run something in the R console to identify the process that would be totally fine.
Is it possible to embed Neovim into RStudio?
I did have a look around but I couldn't see that anyone has done this yet. Neovim does actually seem to run fine inside the RStudio terminal, so that might actually be a good option if it was possible to connect Nvim-R to an already running RStudio. You might even be able to identify the RStudio process automatically because Neovim would be a child process of it in that situation.
Did you try the command :RStop?
I think that starting Neovim in the RStudio's terminal will not work because RStudio cannot natively receive remote messages.
It seems that @matsburg has a solution to your big data.frame problem. See https://github.com/jalvesaq/Nvim-R/issues/416
Short answer: it's not impossible, but it would be highly cumbersome to manually set all variables required to connect an already running R session. The easiest solution to a problem such as this is to split the script into two or more ones before the system's memory is completely consumed by R, run one script and close R, open another script, and so on...