USING 64-BIT R FROM WITHIN AQUAMACS
1) Aquamacs is terrific because it comes bundled with about everything you need to start using R with it. No need to separately download ESS (emacs speaks statistics) or mess with the .ess-lisp files. Download Aquamacs from http://aquamacs.org/ and install it.
2) Now any file with an “.R” extension that is opened with aquamacs will automatically have syntax highlighting AND will allow you to start 64-bit R. I highly recommend checking out this page, http://ess.r-project.org/, and downloading the ESS reference card therein if you are new. Emacs has a bit of a learning curve, but you’ll begin loving its capabilities as an aid to programming very soon.
3) To start 64-bit R from within aquamacs hit <Control>-u then <Alt>-x then “R” then <Return>. Aquamacs will ask you for “Starting Args”. Here’s where you tell it you want to run 64-bit R. Type “--arch=x86_64” then <Return>. A new window will open up that is the R session.
4) That’s almost it. Just one more issue: graphing will crash (something to do with the new R and X11). Aquamacs has X11 as the default (null) graphics device. To change this, type in R: “options(device=”quartz”)”. Now your null graphics device is quartz and it should all work out. If you really want to use X11 to write graphics, you can use x11(type="Xlib")' for each new graph. What I do is to set “options(device=”quartz”) within my Rprofile.site file.
USING EMACS TO LOG IN TO A REMOTE SERVER & RUN R INTERACTIVELY
It can be very helpful to run an interactive session of R on a remote server, which may have faster CPUs and more memory than the computer you’re on, or may have datasets on it you don’t have access to otherwise. This is simple to do using aquamacs. Here’ how:
1) Open up your *.R script you’d like to use
2) Open a shell inside Emacs by typing “M-x shell”
3) From within this shell, ssh to the server you want to use. When doing this, you need to make sure to specify two important ssh options: compression (which compress data coming to you, making the connection seem *much* faster) and X11 forwarding (which allows you to use interactive graphing features via X11). E.g.:
ssh -XC firstname.lastname@example.org
4) You should now be logged into the server, just as you wold be if you’d used terminal rather than emacs. Now open up R as you usually would on that server. E.g.:
5) You should be in R now. To allow this R session to be linked to your *.R script, use this command in the remote R session:
In the Emacs mini-buffer prompt, type:
6) Now you should be able to send code from your *.R script to the remote R session as you normally would (e.g., C-c C-j).
7) Last, you need to change the options in your remote R session to graph using X11 rather than whatever default driver is being used. To do this in R, type:
8) That’s it. Make sure it all works by typing something like:
hist(rnorm(50)) #which should return a histogram of rnorm to your screen!