Perhaps you know of the defunct Smultron, a lightweight editor for Mac OS X. There exists a new version called Fraise, with the same features. Among them, R syntax highlighting and the possibility to interact with the R Gui console.
To do so, when in Fraise, just push Cmd-B to open the Commands window, then create a new command, and type
osascript -e ‘tell application “R.app” to activate’
osascript -e “tell application \”R.app\” to cmd \”setwd(‘%%d’)\”“
osascript -e “tell application \”R.app\” to cmd \”source(file=’%%p’,
You can assign a keyboard shortcut to this command. Whenever you will hit the keys, R.app will activate, set the good working directory, and execute your code. Now, you see that it is straightforward to modify this code / create another so that you execute the selected text only.