STA244 Linear Models

Course Home | Computing Links | Course Calendar | Course Info | Duke Statistics Home | Duke


Running R/S-Plus in Emacs

For those running R/S-Plus within Unix (or Windows), I highly recommend running R or S-Plus from within emacs. This provides command history and editing, command line completion, and simplifies writing source files, functions, provides transcripts of sessions, etc everything but your laundry...

To get started, place the following lines in your ~/.emacs file or save the following .emacs file in order to get access to ESS (Emacs Speaks Statistics). You will need to comment out some of the lines below that are no longer needed in Duke Statistics.



; automatically get the correct mode 
auto-mode-alist (append (list '("\\.c$" . c-mode)
			      '("\\.tex$" . latex-mode)
			      '("\\.S$" . S-mode)
			      '("\\.s$" . S-mode)
			      '("\\.R$" . R-mode)
			      '("\\.r$" . R-mode)
			      '("\\.html$" . html-mode)
                              '("\\.emacs" . emacs-lisp-mode)
	                )
		      auto-mode-alist)
; comment out the following if you are not using R/S-Plus on ACPUB
; add a ";" in front of each line 
(load "/usr/pkg/ess/lisp/ess-site")
(setq-default inferior-S+6-program-name "Splus")
(setq-default inferior-R-program-name "R")


Having done the above, type emacs & to open an emacs window. Ttype M-x R (or S for S-Plus users) and then enter the subdirectory in which you wish to run R/S. (M-x means press the Esc key and then press x) Commands can be placed in a separate file (this is useful for keeping a record of what you have done so far). Extensions for R mode end in .R or .r by default; for S use .S or .s as a file suffix.

Basic ESS commands to get started using R/S-Plus under Emacs ( C-c means press the Ctrl key down and then enter c. )


R/Splus under windows can also be run under Emacs. Please see your local friendly system administrator if you wish to try to set this up on your own computer.


Updated January 13, 2003