Categories: Emacs Tags: Emacs

I’m still using consult to make fun, little Emacs packages that improve my everyday work. This time, I wrote a little package called pop-data-frame.

The idea of pop-data-frame is to work with Emacs Speaks Statistics to help the analyst quickly iterate on R code.

Often, we are using R to manipulate large data.frames, and it’s helpful to have a way to quickly visualize the effects of our data cleaning code on data.frames. Rstudio solves this problem by having a little view window that shows a small snippet of the current data.frame. This is handy, but Emacs has no such viewer. I actually wrote a viewer like this, using tabulate-list-mode in Emacs, but I’m not skilled enough at elisp to make it fast and robust.

Then I figured that it’s better to pop data.frames from the R session into Excel for inspection. This is fast, and the tools for inspecting data.frames in Excel are better than what Emacs has anyway.

The way pop-data-frame works is by prompting the user for a data.frame from the current R session. The selected data.frame is then written to a temporary folder in the file system. Finally, we use Consult to select the system default program for viewing csv files to view the data.frame. This is all just one command called pop-data-frame, so the user doesn’t need to go through the required steps of writing the data frame to disk, and then switching to Excel.

You can install the code from Github:

(use-package pop-data-frame
  :defer t
  :after ess-r-mode
  :straight (:host github :repo "jthaman/pop-data-frame"))