[ESS] using ess-rdired

Sebastian Luque sluque at mun.ca
Wed Dec 1 06:39:56 CET 2004

Dear List,

Sometime ago I was trying to get some of the functionality of Dr. Fox's
init.el file for XEmacs in Emacs. I quickly ran into problems I couldn't
solve with the elisp knowledge I had, but the search led me to Stephen
Eglen's ess-rdired.el, which provides a good deal of the functionality I was
after in Emacs. To my surprise, Stephen told me that ess-rdired.el is already
distributed with ESS, so I only had to look into that file to find how to use
it, and also some great ideas for working with Emacs, R, and ESS.
ess-rdired.el does not yet have an entry in the ESS manual, so here is a
short description and usage information (also included in ess-rdired.el), as
well as a method to work with it. Other List members may find other ways of
using it or customizations that would be great to hear.

1. Load ess-rdired.el if it's not already in your load-path with, e.g.:

(autoload 'ess-rdired "ess-rdired" "View *R* objects in a dired-like buffer."

If you're using Debian and you installed the Debian ESS package, the ess
directory was added to the load-path during installation, so this step isn't
necessary in Debian at least.

2. Start R, as usual, with M-x R, and add a few objects:

x <- rnorm(20)
y <- sin(seq(from=0, to=8*pi, length=100))
z <- as.data.frame(matrix(rnorm(100), 25, 5))
xyz <- list(x, y, z)

4. Run ess-rdired with M-x ess-rdired to create a buffer listing the objects
in your current environment and display it in a new window. The new buffer
uses an ess-rdired-mode keymap and is set as read-only to present the list of
objects, as well as their mode and length. Typing '?' or 'C-h m' provides
help on the bindings used for the mode.

ess-rdired mode provides an efficient method for viewing and performing basic
operations on R objects. For instance, you can move to the line listing
object x or y, and type 'p' to plot it, 'v' to view it, 'd' to mark it for
deletion, or 'y' to show what type it is in the minibuffer. Typing 'd' or 'u'
with point on the top row will select all objects for deletion or unmark
them, which can then be expunged by typing 'x', as you would in dired mode.

I found this to be much better than using the ESS process buffer for tasks
such as listing and performing basic operations on objects. However, I prefer
to have the *R dired* buffer in a separate frame, and since I use framepop.el
anyway, I included the following in my .emacs:

(setq special-display-buffer-names ("*R dired*")
      framepop-do-not-display-list ("*R dired*")

_after_ activating framepop with (setq framepop-enable t). My goal was to have
*R dired* in a separate buffer, while still being able to easily navigate
back and forth from/to other buffers produced while in *R dired*. If you
deactivate framepop completely, and do not specify the second line above,
then *R dired* will be in a new frame, but buffers produced from it will be
displayed in the previous frame, hiding the one with the ESS process.
Conversely, if special-display-buffer-names is not specified, then a single
framepop picks up the *R dired* buffer and everything produced from it, but
the drawback is that in framepop you cannot switch buffers. Having both
variables set like that keeps a frame for *R dired* and buffers produced from
it are picked up by framepop, leaving the frame with the ESS process intact.
It's not an ideal setup, but works for now.

I'm slowly binding some key sequences to some favorite object handling
functions to add to ess-rdired-mode-map. I'm also (again, very slowly!)
trying to put the buffers that ess-rdired functions produce in a some small
mode allowing for navigation from/to ess-rdired buffers while remaining in a
framepop or a special display frame. For now, I wanted to make folks aware of
ess-rdired and see what others thought of using it this way.

Thanks to Stephen for such a great mode!

Best wishes,

More information about the ESS-help mailing list