If you use Emacs and ESS to run R, then here’s a nice tweak I found on the Emacs Wiki. The following bit of elisp goes in your .emacs file (or equivalent). Starting with an R file in the buffer, hitting shift-enter vertically splits the window and starts R in the right-side buffer. If R is running and a region is highlighted, shift-enter sends the region over to R to be evaluated. If R is running and no region is highlighted, shift-enter sends the current line over to R. Repeatedly hitting shift-enter in an R file steps through each line (sending it to R), skipping commented lines. The cursor is also moved down to the bottom of the R buffer after each evaluation. Although you can of course use various emacs and ESS keystrokes to do all this (C-x-3, C-c-C-r, etc, etc) it’s convenient to have them bound in a context-sensitive way to one command.
Make Shift-Enter do a lot in ESS (shift-enter-ess.el)download
;; Adapted with one minor change from Felipe Salazar at;; http://www.emacswiki.org/emacs/EmacsSpeaksStatistics(setqess-ask-for-ess-directorynil)(setqess-local-process-name"R")(setqansi-color-for-comint-mode'filter)(setqcomint-scroll-to-bottom-on-inputt)(setqcomint-scroll-to-bottom-on-outputt)(setqcomint-move-point-for-outputt)(defunmy-ess-start-R()(interactive)(if(not(member"*R*"(mapcar(functionbuffer-name)(buffer-list))))(progn(delete-other-windows)(setqw1(selected-window))(setqw1name(buffer-name))(setqw2(split-windoww1nilt))(R)(set-window-bufferw2"*R*")(set-window-bufferw1w1name))))(defunmy-ess-eval()(interactive)(my-ess-start-R)(if(andtransient-mark-modemark-active)(call-interactively'ess-eval-region)(call-interactively'ess-eval-line-and-step)))(add-hook'ess-mode-hook'(lambda()(local-set-key[(shiftreturn)]'my-ess-eval)))(add-hook'inferior-ess-mode-hook'(lambda()(local-set-key[C-up]'comint-previous-input)(local-set-key[C-down]'comint-next-input)))(add-hook'Rnw-mode-hook'(lambda()(local-set-key[(shiftreturn)]'my-ess-eval)))(require'ess-site)