You can get to work with the help of some third-party components.
When you call Rscript's browseURL function, it's just running whatever program it thinks is the browser and passing it your URL. You can tell it to use whatever "browser" you want:
browseURL("file:/path/to/my/file.html",
browser = "/path/to/chrome_reloader.sh")
You can use the Chromix Too package to control Chrome. You will have to install a few things, but it's easy and only takes a few minutes:
- Install the Chromix Too extension from the Chrome web store.
- Install the latest version of NodeJS.
- Use
npm (installed with NodeJS) to install Chromix Too.
- Run the Chromix Too server.
Now you run commands like chromix-too ls to see a list of all the tabs you have open in Chrome and chromix-too reload http://some.web.site/ to reload one of them.
Now you can write the chrome_relauncher.sh script that just passes whatever URL it gets to chromix-too reload:
#!/bin/bash
chromix-too reload $1
It looks like reload only reloads a tab that already exists but won't open a new one. You could use the ls command to first check if the tab exists; it looks like chromix-too ls 'http://some.site/path' returns success (0) if the tab exists and failure (1) if it doesn't, so you could use that in your script. Or just open the tab manually before running your Rscript program. There's also a file command that loads a local file and specifically says it will reuse and reload an existing tab.
You may need to tweak a few things (maybe add the path to chromix-too which you can get with which chromix-too) but this should basically work.