~ubuntu-branches/ubuntu/raring/ess/raring-proposed

« back to all changes in this revision

Viewing changes to etc/useR-2006-ESS/useR-ESS.tex

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2011-02-03 16:10:05 UTC
  • mfrom: (1.2.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20110203161005-g1bg3cd5mtu15uh3
Tags: 5.13-1
New upstream version released today

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
\documentclass{beamer}
 
2
 
 
3
\mode<presentation>
 
4
{
 
5
  \usetheme{Warsaw}
 
6
  \setbeamercovered{transparent}
 
7
}
 
8
 
 
9
 
 
10
\usepackage[english]{babel}
 
11
\usepackage[latin1]{inputenc}
 
12
\usepackage{times}
 
13
\usepackage[T1]{fontenc}
 
14
% Or whatever. Note that the encoding and the font should match. If T1
 
15
% does not look nice, try deleting the line with the fontenc.
 
16
 
 
17
 
 
18
\title[Emacs and R]{Emacs enhances data analysis and programming with R}
 
19
\subtitle{ESS useR Short Course} 
 
20
\author[Rossini]{A.J.~Rossini}
 
21
 
 
22
\institute[Novartis Pharma AG]
 
23
{
 
24
  Modeling and Simulation \\
 
25
  Novartis Pharma AG \\
 
26
  Basel, Switzerland
 
27
}
 
28
 
 
29
\date[14.06.2006]
 
30
{14.06.2006 / useR-2006}
 
31
 
 
32
\subject{Talks}
 
33
% This is only inserted into the PDF information catalog. Can be left
 
34
% out. 
 
35
 
 
36
% Delete this, if you do not want the table of contents to pop up at
 
37
% the beginning of each subsection:
 
38
% \AtBeginSubsection[]
 
39
% {
 
40
%   \begin{frame}<beamer>
 
41
%     \frametitle{Outline}
 
42
%     \tableofcontents[currentsection,currentsubsection]
 
43
%   \end{frame}
 
44
% }
 
45
 
 
46
 
 
47
\begin{document}
 
48
 
 
49
\begin{frame}
 
50
  \titlepage
 
51
\end{frame}
 
52
 
 
53
\section{Introduction}
 
54
 
 
55
\begin{frame}
 
56
  \frametitle{Outline}
 
57
  %% \tableofcontents[hideallsubsections]
 
58
  \begin{enumerate}
 
59
  \item Introduction (now, 15 minutes)
 
60
  \item Using Emacs (45 minutes)
 
61
  \item Using ESS (60 minutes)
 
62
  \item Exercise 1: ESS
 
63
  \item Exercise 2: Sweave
 
64
  \item Emacs extensions (30 minutes)
 
65
  \item Emacs Lisp (30 minutes)
 
66
  \item Discussion and Misc Topics (related Emacs tools, ESS extensions, future designs)
 
67
  \end{enumerate}
 
68
\end{frame}
 
69
 
 
70
\subsection[Goals]{Goals for Today}
 
71
 
 
72
\begin{frame}
 
73
  \frametitle{\#1: Efficient Program Editing}
 
74
  \framesubtitle{Edit, and let the computer repeat}
 
75
  \begin{itemize}
 
76
  \item Weird archaic keystrokes are dominant
 
77
  \item Weird archaic keystrokes can make life easier
 
78
  \item Menus and toolbars help Emacs
 
79
  \item Knowing R and data analysis means we can enhance related activities.
 
80
  \item Folding editors, Object explorers
 
81
  \end{itemize}
 
82
\end{frame}
 
83
 
 
84
\begin{frame}
 
85
  \frametitle{\#2: Process Interaction}
 
86
  \framesubtitle{You enter text for the process, so edit\ldots}
 
87
  \begin{itemize}
 
88
  \item R vs. ``emacs -f R''
 
89
  \item Getting Help
 
90
  \item Approaches for interacting
 
91
  \item Practical Directory layout
 
92
  \end{itemize}
 
93
\end{frame}
 
94
 
 
95
\begin{frame}
 
96
  \frametitle{\#3: Emacs is Extended and Extensible}
 
97
  \framesubtitle{Lisp and other hackers are your friends}
 
98
  \begin{itemize}
 
99
  \item Introduction to Lisp and Emacs Lisp
 
100
  \item Lisp extends Emacs
 
101
  \item Design of ESS
 
102
  \item Future Extensions??
 
103
  \end{itemize}
 
104
\end{frame}
 
105
 
 
106
%% \begin{frame}
 
107
%%   \frametitle{Make Titles Informative.}
 
108
%%   You can create overlays\dots
 
109
%%   \begin{itemize}
 
110
%%   \item using the \texttt{pause} command:
 
111
%%     \begin{itemize}
 
112
%%     \item
 
113
%%       First item.
 
114
%%       \pause
 
115
%%     \item    
 
116
%%       Second item.
 
117
%%     \end{itemize}
 
118
%%   \item
 
119
%%     using overlay specifications:
 
120
%%     \begin{itemize}
 
121
%%     \item<3->
 
122
%%       First item.
 
123
%%     \item<4->
 
124
%%       Second item.
 
125
%%     \end{itemize}
 
126
%%   \item
 
127
%%     using the general \texttt{uncover} command:
 
128
%%     \begin{itemize}
 
129
%%       \uncover<5->{\item
 
130
%%         First item.}
 
131
%%       \uncover<6->{\item
 
132
%%         Second item.}
 
133
%%     \end{itemize}
 
134
%%   \end{itemize}
 
135
%% \end{frame}
 
136
 
 
137
\begin{frame}
 
138
  \frametitle{Disclaimer}
 
139
  \begin{itemize}
 
140
  \item ESS (and Emacs) is many (different) things to different
 
141
    people.
 
142
  \item Even for R development, the variation in personal philosophies
 
143
    and approaches for use is extremely high (even in the Core
 
144
    development team).
 
145
  \item Religious issues focusing on Emacs should be discussed elsewhere 
 
146
    (c.f. \url{http://www.dina.kvl.dk/~abraham/religion/})
 
147
  \end{itemize}
 
148
\end{frame}
 
149
 
 
150
\begin{frame} \frametitle{Demo!}
 
151
  \framesubtitle{It'll get boring before it gets better\ldots}
 
152
  \alert{Please note or comment on any part that you'd like covered later.}
 
153
\end{frame}
 
154
 
 
155
\subsection{Introducing Emacs}
 
156
 
 
157
\begin{frame} \frametitle{Overview}
 
158
  \begin{itemize}
 
159
  \item Emacs is the extensible, customizable, self-documenting
 
160
    real-time display editor.
 
161
  \item One of the oldest and yet still most powerful display editors
 
162
  \item The name \textbf{Emacs} comes from Editor (or Extensible)
 
163
    MACroS. (source of other amusing acronym expansions)
 
164
  \item Originally written in 1976 as a set of extensions to TECO
 
165
    (Text Editor and COrrector).  It has since evolved.
 
166
  \end{itemize}
 
167
\end{frame}
 
168
 
 
169
\begin{frame} \frametitle{Pros and Cons for Emacs}
 
170
  \begin{itemize}
 
171
  \item \alert{Why use Emacs?}  It is a powerful text editor which
 
172
    can be extended to be a general interface to a computer (everything can be done within it).
 
173
  \item It is highly portable (in its own way) across many platforms.
 
174
  \item \alert{Why do not use it?} It has a different user interface,
 
175
    which is understandable given its age (little change since 1985).
 
176
  \item It does not follow ``modern'' keybindings.
 
177
  \item People don't understand Lisp (otherwise, what they want to do
 
178
    could be done in Emacs)
 
179
  \end{itemize}
 
180
  \centerline{\alert{some people are allergic to it}}
 
181
\end{frame}
 
182
 
 
183
\begin{frame}
 
184
  \frametitle{On-line Resources}
 
185
  Links to links:
 
186
  \begin{itemize}
 
187
  \item Emacs Wiki: \url{http://www.emacswiki.org/}
 
188
  \item Emacs \url{http://www.gnu.org/software/emacs/}
 
189
  \item XEmacs \url{http://www.xemacs.org/}
 
190
  \item Emacs Lisp Library \url{http://www.damtp.cam.ac.uk/user/sje30/emacs/ell.html}
 
191
  \end{itemize}
 
192
\end{frame}
 
193
 
 
194
\begin{frame}
 
195
  \frametitle{The Emacsen Problem}
 
196
  \framesubtitle{different religions cause stress}
 
197
  There are many variants or dialects of Emacs (\textit{similar to the
 
198
    S language having AT\&T's S, Insightful's S-PLUS, and R-core's R})
 
199
  \begin{itemize}
 
200
  \item Emacs: ``classic version''
 
201
  \item XEmacs: ``experiments'' (GUIs, dynamic loading, packaging)
 
202
  \item SXEmacs: ``splinter'' (Unix-focus, streamlining XEmacs)
 
203
  \end{itemize}
 
204
  
 
205
  ESS support is best in order (Emacs, XEmacs, SXEmacs).  Most active
 
206
  ESS developers use Emacs.  Users seem to be split 50/50 between
 
207
  Emacs and XEmacs.\\
 
208
  No bug reports on SXEmacs\ldots 
 
209
\end{frame}
 
210
 
 
211
\begin{frame}
 
212
  \frametitle{Installation}
 
213
  \framesubtitle{the bane of Emacs}
 
214
  Installation can be tricky:
 
215
  \begin{itemize}
 
216
  \item Linux: Emacs usually can be installed or is preinstalled
 
217
  \item Microsoft: XEmacs is easier to install, Emacs might be better
 
218
    supported.
 
219
  \item Mac OSX: Emacs, AquaEmacs; via Fink, or UCLA package, or\ldots
 
220
    (check on the list).
 
221
  \end{itemize}
 
222
  We aren't dealing with this here!
 
223
\end{frame}
 
224
 
 
225
\begin{frame} \frametitle{Editing methodology}
 
226
  \framesubtitle{Emacs resembles modern editors unlike dual-mode VI}
 
227
 
 
228
  \begin{itemize}
 
229
  \item Idea: every keystroke (or sequence of keystrokes) generates a
 
230
    list to evaluate (i.e. command, or lisp function with arguments).
 
231
  \item Pressing ``X'' evaluates the list (self-insert-command "X")  (we'll talk about Lisp later)    
 
232
  \item Modifiers extend the keyboard (CTL, SHIFT, ALT, pressed
 
233
    simultaneously, some such as ESC, META, and others are pressed
 
234
    first, released, and then followed by a key).
 
235
  \end{itemize}
 
236
\end{frame}
 
237
 
 
238
\subsection{Introducing ESS}
 
239
 
 
240
\begin{frame}
 
241
  \frametitle{Overview}
 
242
  \framesubtitle{ESS augments Emacs for R}
 
243
  \begin{itemize}
 
244
  \item Emacs Speaks Statistics (or Emacs Statistical System)
 
245
  \item Oldest active statistically-focused OSS project (1989).
 
246
  \item Design goal: a consistent interface unifying batch and
 
247
    interactive data analysis styles.
 
248
  \item Novelty (at the time): process control, unified interface. 
 
249
  \item String (stream) operations; ``cheap parser''.
 
250
  \item Supports R, S-PLUS, SAS, Stata, LispStat
 
251
  \item Current development team (n=6) spans the US and Europe.
 
252
  \end{itemize}
 
253
\end{frame}
 
254
 
 
255
\begin{frame} \frametitle{History}
 
256
  \begin{itemize}
 
257
  \item 3 branches: S-mode, SAS-mode, Stata-mode
 
258
  \item S-mode: 1989, 2 groups managing the project before (Bates/F
 
259
    Ritter/E Kademan, M Meyer, DM Smith (now Insightful)).
 
260
    R added in 1995 (Rossini/Maechler)
 
261
  \item SAS: '94, Tom Cook ('92, John Sall, SAS).  Integrated '95-6, Rossini
 
262
  \item Stata-mode: 1997, Thomas Lumley. Added 1997 (Rossini). 
 
263
  \item 1997: last major restructuring (``grand unification'')
 
264
  \item 2004: switch leaders: Maechler takes over
 
265
  \end{itemize}
 
266
  \alert{We are still suffering from the 1997 grand unification.}
 
267
\end{frame}
 
268
 
 
269
\begin{frame}
 
270
  \frametitle{Interactive Programming}
 
271
  \framesubtitle{Everything goes back to being Lisp}
 
272
  \begin{itemize}
 
273
  \item Interactive programming (as originating with Lisp): works
 
274
    extremely well for data analysis (Lisp being the original
 
275
    ``programming with data'' language).
 
276
  \item Theories/methods for how to do this are reflected in styles
 
277
    for using ESS.
 
278
  \end{itemize}
 
279
  \alert{Good Statistical Analysis is on-line Interactive Programming}
 
280
\end{frame}
 
281
 
 
282
\begin{frame}
 
283
  \frametitle{Installation}
 
284
  \framesubtitle{We have to deal with this here, though\ldots}
 
285
  \begin{itemize}
 
286
  \item Fetch the ESS package (tar or zip-file)
 
287
  \item unpack
 
288
  \item add a line in \textbf{.emacs} to load the \textbf{ess-site.el} file.
 
289
  \item restart Emacs (or \textbf{M-x load-file /path/to/ess-site.el}).
 
290
  \end{itemize}
 
291
\end{frame}
 
292
 
 
293
\begin{frame}
 
294
  \frametitle{Review: Introduction}
 
295
  \begin{itemize}
 
296
  \item ESS is a program in Lisp to extend Emacs
 
297
  \item Characteristics: OSS, developed initially to make life easier;
 
298
    continued development supported research in enhanced data analysis
 
299
    interfaces.
 
300
  \item Emacs has strengths and weaknesses; these are usually
 
301
    different than percieved strengths and weaknesses.
 
302
  \end{itemize}
 
303
\end{frame}
 
304
 
 
305
\section{Using Emacs}
 
306
 
 
307
\subsection{Overview: Emacs}
 
308
 
 
309
\begin{frame} \frametitle{Goals}
 
310
  \begin{itemize}
 
311
  \item use of Emacs to edit files
 
312
  \item filesystem interaction
 
313
  \end{itemize}
 
314
\end{frame}
 
315
 
 
316
\subsection{Getting Started}
 
317
 
 
318
\begin{frame}[fragile]
 
319
  \frametitle{Starting (X)Emacs}
 
320
  \framesubtitle{trivial but essential}
 
321
  \alert{emacs} can be used instead of \alert{xemacs}.
 
322
\begin{verbatim}
 
323
xemacs <filename>  run xemacs, edit <filename>
 
324
xemacs -nw         run xemacs in _text_ mode
 
325
                   (nw="No Window"; useful for 
 
326
                    slow remote connections)
 
327
\end{verbatim}
 
328
  \begin{itemize}
 
329
  \item Once started, no need for more.
 
330
  \item \alert{Only run one Emacs session}.  This is a cardinal rule,
 
331
    do not violate it.
 
332
    (c.f.\hyperlink{keystrokes:fileloading}{\beamerbutton{file-loading section}})
 
333
  \end{itemize}
 
334
\end{frame}
 
335
 
 
336
 
 
337
\begin{frame}[fragile]
 
338
  \frametitle{Breaking and Quitting!}
 
339
  \framesubtitle{essential knowledge}
 
340
  \label{emacs:basics}
 
341
  \begin{itemize}
 
342
  \item Decide you were wrong while Emacs works: \verb+C-g+  (universal break)
 
343
  \item Quit and terminate: \verb+C-x C-c+ (will usually prompt you
 
344
    for any files which are modified but not saved)
 
345
  \end{itemize}
 
346
\end{frame}
 
347
 
 
348
 
 
349
\begin{frame}[fragile]
 
350
  \frametitle{Understanding Keystrokes.}
 
351
  \begin{itemize}
 
352
  \item \verb+[tab]+ is the TAB (indent) key.
 
353
  \item \verb+[return]+ is the Return (carriage return, enter) key.
 
354
  \item \textbf{C-h} means press \alert{control key} AND ``\alert{h}'' key at same time.
 
355
  \item \textbf{ESC-h} means press \alert{ESC key} THEN ``\alert{h}''
 
356
  \item \textbf{M-h} means press \alert{ALT key} AND ``\alert{h}''
 
357
  \item \textbf{M-C-h} means press Meta or Alt while pressing h.  OR
 
358
    (if no meta/alt): ESC THEN (control and h keys together).
 
359
  \end{itemize}
 
360
  Older keyboards (and sometimes older Macs) without ALT or Meta lead
 
361
  to confusion between ESC and Meta, but ideally they should be different.
 
362
\end{frame}
 
363
 
 
364
\begin{frame} \frametitle{Stopping Activity}
 
365
  \framesubtitle{you need to know this\ldots}
 
366
  \alert{C-g} stops the current Emacs activity to the best of its ability.
 
367
\end{frame}
 
368
 
 
369
\begin{frame}
 
370
  \frametitle{Windows and Frames}
 
371
  \begin{itemize}
 
372
  \item Window:  a different view on (usually) a different buffer within the same application
 
373
  \item Frame: a different window/application in the windowing system.
 
374
  \end{itemize}
 
375
\end{frame}
 
376
 
 
377
\begin{frame}[fragile]
 
378
  \frametitle{File suffices drive mode setup}
 
379
  \framesubtitle{Use the right file name formats:}
 
380
  \begin{itemize}
 
381
  \item \verb+.S+, such as \verb+critical_simulation.S+
 
382
  \item \verb+.R+, such as \verb+speedy_simulation.R+
 
383
  \end{itemize}
 
384
  There are other ways to force a file to be edited in a particular
 
385
  mode, but at this point, keep it simple.
 
386
\end{frame}
 
387
 
 
388
\begin{frame}
 
389
  \frametitle{Commands}
 
390
  
 
391
  Emacs has a single command-entry mode.  There are 2 approaches for commands:
 
392
  \begin{itemize}
 
393
    \item \textbf{M-x (command-name)}
 
394
    \item keystrokes/toolbars/menus (which implement the above)
 
395
  \end{itemize}
 
396
  
 
397
\end{frame}
 
398
 
 
399
\subsection{Keystrokes}
 
400
 
 
401
\begin{frame}
 
402
  \frametitle{Learning the Strokes.}
 
403
  \begin{itemize}
 
404
  \item forced practice: painful but fast.  Keep a copy of the
 
405
    reference cards nearby!  (usually 2-3 days of severe pain,
 
406
    followed by bliss).
 
407
  \item accelerators and menus can help: but they quickly become a crutch.
 
408
  \item Consider working through the tutorial (\textbf{C-h t}).
 
409
  \end{itemize}
 
410
  \alert{this is a major issue for speed typists converting to/from
 
411
    Emacs usage.}
 
412
\end{frame}
 
413
 
 
414
\begin{frame}[fragile]
 
415
  \frametitle{Loading Files}
 
416
  \label{keystrokes:fileloading}
 
417
  \begin{itemize}
 
418
  \item \verb+C-x C-f+    (load new file, \textbf{not} deleting old)
 
419
  \item \verb+C-x 4 C-f+  (load new file in different window)
 
420
  \item \verb+C-x 5 C-f+  (load new file in different frame)
 
421
  \end{itemize}
 
422
  (c.f. \hyperlink{emacs:basics}{\beamerbutton{basics}})
 
423
\end{frame}
 
424
 
 
425
\begin{frame}[fragile]
 
426
  \frametitle{Changing Active Buffer (edit file)}
 
427
  To edit (operate on) another file:
 
428
  \begin{itemize}
 
429
  \item \verb+C-x b+    (switch to new buffer in same window)
 
430
  \item \verb+C-x 4 b+  (replaces current file in different window)
 
431
  \item \verb+C-x 5 b+  (replaces current file in different frame)
 
432
  \end{itemize}
 
433
  Buffers represent the files you are editing (explain).
 
434
\end{frame}
 
435
 
 
436
\begin{frame}
 
437
  \frametitle{Review of Common Keystrokes}
 
438
  \framesubtitle{Demo and pain}
 
439
\end{frame}
 
440
 
 
441
 
 
442
\subsection{In Any Emacs Buffer}
 
443
 
 
444
\begin{frame}[fragile] \frametitle{Moving Around}
 
445
\begin{verbatim}
 
446
C-v    Move forward one screenful
 
447
M-v    Move backward one screenful
 
448
C-l    Clear and redraw screen
 
449
M- ->  Meta-<right> - moves forward a word 
 
450
M- <-  Meta-<left> - moves back a word
 
451
M- |^  Meta-<up> - move up a paragraph
 
452
M- V   Meta-<down> - move down a paragraph
 
453
M- <   Meta-<less than> - move to file start
 
454
M- >   Meta-<greater than> - move to file end
 
455
\end{verbatim}
 
456
\end{frame}
 
457
 
 
458
\begin{frame}[fragile] \frametitle{Cut and Paste}
 
459
\begin{verbatim}
 
460
C-d    _D_elete
 
461
C-k    _K_ill from the cursor position to
 
462
       end of line
 
463
C-y    Recover/Paste (_Y_ank) killed text 
 
464
       (repeat to copy) 
 
465
M-y    recover former killed text (after C-y).
 
466
       Repeat to go back through stack).
 
467
C-x u  _U_ndo
 
468
\end{verbatim}
 
469
\end{frame}
 
470
 
 
471
 
 
472
\begin{frame}[fragile] \frametitle{Loading / Saving Files}
 
473
\begin{verbatim}
 
474
C-x C-f  _F_ind a file
 
475
C-x C-s  _S_ave the file
 
476
 
 
477
If you find a second file with C-x C-f, 
 
478
the first file remains inside Emacs.  
 
479
You can switch back to it by finding it 
 
480
again with C-x C-b.  This way you can get 
 
481
quite a number of files inside Emacs.
 
482
 \end{verbatim}
 
483
\end{frame}
 
484
 
 
485
 
 
486
\begin{frame}[fragile] \frametitle{Managing Buffers and Windows}
 
487
\begin{verbatim}
 
488
C-x 0      Move between windows  
 
489
           (Oh, not Zero!)
 
490
C-x 1      One window 
 
491
           (i.e., kill all other windows).
 
492
C-x b      Switch to new _b_uffer
 
493
C-x C-b    List _b_uffers
 
494
\end{verbatim}
 
495
\end{frame}
 
496
 
 
497
 
 
498
\begin{frame}[fragile] \frametitle{Search and Replace}
 
499
\begin{verbatim}
 
500
M-x (then) replace-string
 
501
           Replace string
 
502
M-x (then) query-replace-string
 
503
           Will ask you, for each match,
 
504
           if you really want to replace
 
505
           the old string with the new one.
 
506
C-s        _S_earch forward (repeat to
 
507
           reuse past search strings)
 
508
C-r        Search _R_everse (repeat to
 
509
           reuse past search strings)
 
510
\end{verbatim}
 
511
\end{frame}
 
512
 
 
513
                     
 
514
\begin{frame}[fragile] \frametitle{Misc Emacs Actions}
 
515
\begin{verbatim}
 
516
C-h or C-h ?    _H_elp
 
517
C-h c (command) _H_elp on this _c_ommand
 
518
 
 
519
C-u 8 (character or command)   
 
520
             Repeat character/command 8 times
 
521
 
 
522
C-g          Stop, unhang.
 
523
C-x C-c      Stop and exit (_c_lose) Emacs  
 
524
\end{verbatim}
 
525
\end{frame}
 
526
 
 
527
 
 
528
\begin{frame}
 
529
  \frametitle{Point and Mark}
 
530
  \framesubtitle{critical concepts to learn}
 
531
 
 
532
  \begin{itemize}
 
533
  \item Point:  where the cursor is.
 
534
  \item Mark: a location that you've decided (actively or inactively)
 
535
    is important.
 
536
  \item Example:   Move cursor somewhere.  \textbf{M-x set-mark} or
 
537
    \textbf{C-(space)}.
 
538
  \item Exchange point and mark:   \textbf{M-x
 
539
      exchange-point-and-mark} or \textbf{C-x C-x}.
 
540
  \end{itemize}
 
541
\end{frame}
 
542
 
 
543
\subsection{Review: Using Emacs}
 
544
 
 
545
\begin{frame}
 
546
  \frametitle{Review}
 
547
  \framesubtitle{Emacs}
 
548
  \begin{itemize}
 
549
  \item \textbf{C-g} stops emacs activity and returns to edit mode; \textbf{C-x C-c} quits
 
550
  \item Try to use the keyboard and not the mouse, menus, or toolbars.
 
551
  \item Keypresses are simply commands.
 
552
  \item Biggest user headache?  Differenting commands and text entry
 
553
  \item Buffers represent the files you are editing.  Morally, they
 
554
    are the files themselves (with important exceptions).
 
555
  \end{itemize}
 
556
\end{frame}
 
557
 
 
558
 
 
559
\section{Using ESS}
 
560
 
 
561
\subsection{Overview: ESS}
 
562
 
 
563
\begin{frame}
 
564
  \frametitle{Overview: ESS}
 
565
  This section should provide an overview for 
 
566
  \begin{itemize}
 
567
  \item editing
 
568
  \item interaction with R
 
569
  \item facilitating help
 
570
  \item reusing transcripts
 
571
  \item Sweave support
 
572
  \end{itemize}
 
573
  and finally, \alert{putting it all together}
 
574
\end{frame}
 
575
 
 
576
\subsection{Editing}
 
577
 
 
578
\begin{frame}[fragile]
 
579
  \frametitle{Coding Style}
 
580
  \framesubtitle{Indentation makes code readable}
 
581
 
 
582
  Comment conventions:
 
583
  \begin{enumerate}
 
584
  \item \verb+#+ gets moved to the right-side of the line
 
585
  \item \verb+##+ is placed at the current indentation level
 
586
  \item \verb+###+ is placed flush-left.
 
587
  \end{enumerate}
 
588
\end{frame}
 
589
 
 
590
\begin{frame}[fragile]
 
591
  \frametitle{Indentation Example}
 
592
\begin{verbatim}
 
593
    my.x <- rnorm(10)
 
594
### This is flush
 
595
    ## but this is at level
 
596
                         # this is right
 
597
\end{verbatim}
 
598
\end{frame}
 
599
 
 
600
 
 
601
\begin{frame}[fragile]
 
602
  \frametitle{Editing, ESS adds\ldots}
 
603
  \begin{itemize}
 
604
  \item Automatic fontification, indentation
 
605
  \end{itemize}
 
606
  If R is running in another buffer:
 
607
  \begin{itemize}
 
608
  \item evaluation of lines (C-c C-n), regions (C-c C-r), functions
 
609
    (C-c C-f), and buffers (C-c C-b)
 
610
  \item help output in other buffers (and via command, C-c C-v)
 
611
  \item Object (data, function) completion
 
612
    \begin{itemize}
 
613
    \item \verb+C-c [tab]+ 
 
614
    \item \verb+[tab]+ (sometimes).
 
615
    \end{itemize}
 
616
  \item Filename completion: M-\[tab\]
 
617
  \end{itemize}
 
618
\end{frame}
 
619
 
 
620
\begin{frame}[fragile]
 
621
  \frametitle{R editing buffer}
 
622
  \framesubtitle{Usually named for the file being edited}
 
623
  (mode line says "ESS[S]")
 
624
\begin{verbatim}
 
625
C-c C-j        Send line to R
 
626
C-c C-n        Send line to R 
 
627
               and go to _n_ext line
 
628
C-c C-r        Send highlighted _r_egion to R
 
629
C-c C-b        Send whole _b_uffer to R
 
630
C-c C-f        Send _f_unction surrounding
 
631
               cursor to R
 
632
C-c C-v xxx    get R help on "xxx"
 
633
\end{verbatim}
 
634
\end{frame}
 
635
 
 
636
\subsection{Interactive}
 
637
 
 
638
\begin{frame}
 
639
  \frametitle{Run R}
 
640
  \begin{itemize}
 
641
  \item Within emacs
 
642
  \item At the command line
 
643
  \end{itemize}
 
644
\end{frame}
 
645
 
 
646
\begin{frame}[fragile]
 
647
  \frametitle{R process within Emacs (on start)}
 
648
  \framesubtitle{starting from the command line or launcher}
 
649
  Replace the command \textbf{R} with one of:
 
650
\begin{verbatim}
 
651
emacs -f R        run (x)emacs, starting R
 
652
xemacs -f R       session                   
 
653
\end{verbatim}
 
654
  adds a few nice features to the command interface.  (follow with
 
655
  \textbf{\&} to background the process; \verb+xemacs+ might also
 
656
  work)
 
657
\end{frame}
 
658
 
 
659
\begin{frame}[fragile]
 
660
  \frametitle{R process within Emacs (running emacs)}
 
661
  \framesubtitle{Starting from a running emacs}
 
662
\begin{verbatim}
 
663
M-x R         Start R process buffer
 
664
M-x R-mode    Change mode of current buffer
 
665
              for R code editing
 
666
\end{verbatim}
 
667
\end{frame}
 
668
 
 
669
\begin{frame}[fragile]
 
670
  \frametitle{Evaluate file contents}
 
671
  \framesubtitle{working from the editing (ESS) buffer}. 
 
672
 
 
673
  From a file of commands:
 
674
  \begin{itemize}
 
675
  \item Send current line to R: \verb+C-c C-j+
 
676
  \item Send current function to R (assumes the cursor is in the
 
677
    function body): \verb+C-c C-f+.
 
678
  \item Send current region (highlighted) to R  \verb+C-c C-r+
 
679
  \item Send whole buffer/file to R  \verb+C-c C-b+
 
680
  \end{itemize}
 
681
\end{frame}
 
682
 
 
683
\begin{frame}[fragile]
 
684
  \frametitle{Object and File completion}
 
685
  Completion of objects (functions and data):
 
686
  \begin{enumerate}
 
687
  \item \verb+C-c [tab]+
 
688
  \item \verb+[tab]+ (sometimes).
 
689
  \end{enumerate}
 
690
\end{frame}
 
691
 
 
692
\begin{frame}
 
693
  \frametitle{Dumping Objects}
 
694
  \framesubtitle{Getting objects back}
 
695
  (for modification, saving, eventual reloading):
 
696
  \begin{enumerate}
 
697
  \item \textbf{C-c C-d} dumps the named object into an editing buffer
 
698
  \item Examples: today's date for use as a log file; (140606), ``lm''.
 
699
  \item if object doesn't exist: create a blank buffer
 
700
  \item if object exists: insert the object's textual representation (no comments)
 
701
  \item The file will be stored in \textbf{/tmp/username.objectname.R}
 
702
    (unless you want it elsewhere or named something else).
 
703
  \end{enumerate}
 
704
  Type commands into the edit file, evaluate them when desired, edit
 
705
  as needed for correctness (and comment mistakes, with reasons for
 
706
  them, for later reminders and documentation).
 
707
\end{frame}
 
708
 
 
709
\begin{frame}[fragile]
 
710
  \frametitle{Commandline History}
 
711
  \framesubtitle{ESS remembers what you've done}
 
712
  Search command-line history ``manually'', matching on current input
 
713
  \begin{enumerate}
 
714
  \item backwards: \verb+M-p+
 
715
  \item forwards:  \verb+M-n+
 
716
  \end{enumerate}
 
717
  Complete current line based on command-line history:
 
718
  \begin{enumerate}
 
719
  \item backwards: \verb+\C-[uparrow]-p+
 
720
  \item forwards:  \verb+M-n+
 
721
  \end{enumerate}
 
722
  If you are reviewing old commands, to re-enter it (i.e. cursor on that line)
 
723
  \verb+[return]+.  
 
724
\end{frame}
 
725
 
 
726
\begin{frame}
 
727
  \frametitle{Philosophy: Files are ``truth''}
 
728
  \framesubtitle{Don't believe your .RData}
 
729
  \begin{itemize}
 
730
  \item This is a generally decent approach.
 
731
  \item Saving objects in binary format in special files can be a
 
732
    reasonable strategy
 
733
  \item Work from an R file, \emph{submitting} commands to the R
 
734
    process.  This saves the source, and allows for structuring of the
 
735
    input, along with having a transcript of the order of commands to
 
736
    understand reproducibility aspects.
 
737
  \end{itemize}
 
738
\end{frame}
 
739
 
 
740
\begin{frame}[fragile]
 
741
  \frametitle{Working from R process}
 
742
  \framesubtitle{from the process (inferior ESS, or iESS) buffer}
 
743
  \alert{not usually recommended}
 
744
  \begin{enumerate}
 
745
  \item One improvement is to use a \verb+source()+-like facility.  To
 
746
    source a file into R (within ESS): \textbf{C-c C-l} (load file)
 
747
  \item To find what the errors are (if any): \textbf{C-c `} (backquote).
 
748
  \end{enumerate}
 
749
  The latter will tell you what the error is.  You'll have to go back
 
750
  to the file (\textbf{C-x C-b} or use \textit{Buffers} menu item to
 
751
  bring in back to the screen) and correct it.
 
752
\end{frame}
 
753
 
 
754
\begin{frame}[fragile]
 
755
  \frametitle{Working from R buffer}
 
756
  \framesubtitle{from the editing (ESS) buffer}
 
757
  Better yet, use a file, and send material from the file straight to
 
758
  the process.  This works if the file ends in the proper suffix (and
 
759
  hence, the mode at the bottom should say ``ESS'').  The following is
 
760
  possible:
 
761
  \begin{itemize}
 
762
  \item Send current line to R: \textbf{C-c C-j}
 
763
  \item Send current function to R (assumes the cursor is in the
 
764
    function body): \textbf{C-c C-f}
 
765
  \item Send current region (highlighted) to R: \textbf{C-c C-r}
 
766
  \item Send whole buffer/file to R: \textbf{C-c C-b}
 
767
  \end{itemize}
 
768
\end{frame}
 
769
 
 
770
\begin{frame}
 
771
  \frametitle{Philosophy: RData is true}
 
772
  \framesubtitle{Editing objects without source}
 
773
  \begin{itemize}
 
774
  \item This is a dangerous approach; corruption of the RData file is
 
775
    more difficult to fix using an editor or other external tools than
 
776
    corruption of text files, usually.
 
777
  \item Trusting .RData to have what you've done is rather suboptimal
 
778
    strategy (quite prone to user mistakes)
 
779
  \end{itemize}
 
780
\end{frame}
 
781
 
 
782
\begin{frame}
 
783
  \frametitle{If you must use a command line\ldots}
 
784
  \begin{itemize}
 
785
  \item This style is useful for quick and dirty exercises/testing.
 
786
  \item Transcripts can be cleaned and edited to record the salient
 
787
    points of the sesssion.
 
788
  \end{itemize}
 
789
\end{frame}
 
790
 
 
791
\subsection{Putting it together}
 
792
 
 
793
\begin{frame}
 
794
  \frametitle{Begin ESS/Emacs/R}
 
795
  \begin{enumerate}
 
796
  \item Start XEmacs  (in a terminal window, enter \textbf{xemacs \&})
 
797
  \item Start R (\textbf{M-x R}).
 
798
  \item Load a file (\textbf{C-x C-f} \textit{filename})
 
799
  \end{enumerate}
 
800
\end{frame}
 
801
 
 
802
\begin{frame}[fragile]
 
803
  \frametitle{Data Analysis Example}
 
804
  Demo.
 
805
\end{frame}
 
806
 
 
807
\begin{frame}[fragile] \frametitle{Function Editing}
 
808
  \begin{enumerate}
 
809
  \item demo.R: evaluate.
 
810
  \item Try editing existing functions: \textbf{my.test.function} and
 
811
    \textbf{that}, by \textbf{C-c C-d this}.  Remember that you should
 
812
    be able to complete the name using \textit{ajr.t}\textbf{SPACE}
 
813
    (i.e.  Control-C, then SPACE key).  Generally, completion of
 
814
    variables and functions can be done using \textbf{C-c [tab]} in the
 
815
    editing buffer, and \textbf{SPACE} in the command entry area (at
 
816
    the very bottom of the Emacs screen/window).
 
817
  \end{enumerate}
 
818
\end{frame}
 
819
 
 
820
\subsection{Special Facilities and Activties}
 
821
 
 
822
\begin{frame}
 
823
  \frametitle{Navigating Help Buffers}
 
824
  \begin{itemize}
 
825
  \item To get help on a function (help(``lm'')) without
 
826
    spoiling your input line:  \textbf{C-c C-v}
 
827
  \item Navigation of sections: ``n'' next section, ``p'' prev section.
 
828
  \item evaluation of example: ``l'' (eval line) ``r'' eval region.
 
829
  \item searching: ``/'' isearch forward
 
830
  \item kill-buffer and go \textit{back}: ``x''
 
831
  \end{itemize}
 
832
  See menu items
 
833
\end{frame}
 
834
 
 
835
\begin{frame}
 
836
  \frametitle{Using Transcripts}
 
837
  \framesubtitle{for teaching, reproduction, and audits}
 
838
  \begin{itemize}
 
839
  \item Transcript suffix:  .Rt
 
840
  \item Stepping through entries:
 
841
  \item Cleaning transcripts: \textbf{M-x ess-transcript-clean-buffer}
 
842
  \item Cleaning transcripts: \textbf{M-x ess-transcript-DO-clean-region} (even when read-only toggled)
 
843
  \end{itemize}
 
844
\end{frame}
 
845
 
 
846
\begin{frame}
 
847
  \frametitle{Using Multiple Processes}
 
848
  \framesubtitle{For when you want to multitask}
 
849
  ESS supports multiple processes.   This is useful for 
 
850
  \begin{itemize}
 
851
  \item testing on multiple versions of R
 
852
  \item testing on R and S-PLUS (and S4, if one still has a copy)
 
853
  \item inefficient multiprocessing
 
854
  \end{itemize}
 
855
\end{frame}
 
856
 
 
857
\begin{frame}
 
858
  \frametitle{Using Remote Processes}
 
859
  \framesubtitle{loading other people's computers}
 
860
  Since we are capturing/using R text I/O, local or remote is not an
 
861
  issue (running R in an Emacs shell, logged in (shell account via
 
862
  telnet, ssh, rlogin) to another machine)
 
863
  \begin{itemize}
 
864
  \item \textbf{M-x ESS-remote}
 
865
  \item follow instructions
 
866
  \end{itemize}
 
867
\end{frame}
 
868
 
 
869
\begin{frame}[fragile]
 
870
  \frametitle{Customizing ESS}
 
871
  See (commented out) example customizations in ess-site.el (assuming
 
872
  that the lisp files are installed:
 
873
\begin{verbatim}
 
874
M-x locate-library [return] ess-site [return]
 
875
\end{verbatim}
 
876
  will help.  Also, 
 
877
\begin{verbatim}
 
878
M-x customize-group [return] ess
 
879
\end{verbatim}
 
880
  helps to review possible customizations (this is an alternative to
 
881
  editing the \textbf{\~{}/.emacs} file for setting customizing
 
882
  variables).
 
883
\end{frame}
 
884
 
 
885
\subsection{Sweave Support}
 
886
 
 
887
\begin{frame}
 
888
  \frametitle{Overview: Sweave}
 
889
  Sweave originated from the Literate Data Analysis philosophy which
 
890
  in itself was the idea of applying Literate Programming to the
 
891
  specialized programming discipline \emph{interactive data analysis}.
 
892
 
 
893
  Support for editing Noweb files existed within ESS 4 years before
 
894
  Sweave, but Sweave is a ``Killer App''.
 
895
\end{frame}
 
896
 
 
897
\begin{frame}
 
898
  \frametitle{Documents as Programs}
 
899
  \begin{itemize}
 
900
  \item Every electronic document is a ``computer program'' (sometimes
 
901
    at a primitive level) for some rendering device or program (such
 
902
    as: Microsoft Word; Postscript printers; Adobe Acrobat Reader;
 
903
    Emacs)
 
904
  \item This is the general theory behind the WWW, as well as the
 
905
    so-called \emph{Semantic Web}.
 
906
  \end{itemize}
 
907
\end{frame}
 
908
 
 
909
\begin{frame}
 
910
  \frametitle{Literate Programming} 
 
911
  A programming methodology devised by Donald Knuth in the late 70s,
 
912
  early 80s, which mixes computer programs doing mathematics with
 
913
  mathematical documentation (formulas, theorems, algorithms).
 
914
 
 
915
  2 operations:
 
916
  \begin{itemize}
 
917
  \item Tangling: translating document into undocumented computer source code for
 
918
    compiling.
 
919
  \item Weaving: translating document into documentation for the source code.
 
920
  \end{itemize}
 
921
  The original tool was called Web (predates the \textit{World-Wide-Web}).
 
922
\end{frame}
 
923
 
 
924
\begin{frame} \frametitle{Literate Statistical Practice}
 
925
  \framesubtitle{or \emph{Literate Data Analysis:}}
 
926
  The application of literate programming to statistics; recognizing
 
927
  that statistical data analysis is a specialized programming activity
 
928
  with different characteristics than systems programming or
 
929
  applications programming.
 
930
 
 
931
  (realization prototype: ESS-Noweb and Sweave).
 
932
\end{frame}
 
933
 
 
934
\begin{frame} \frametitle{ESS enhances Sweave}
 
935
  \begin{itemize}
 
936
  \item context specific modes (doc: latex, html, muse; code: R, etc).
 
937
  \item chunk and thread evaluation.
 
938
  \item functions for processing Sweave files.
 
939
  \end{itemize}
 
940
\end{frame}
 
941
 
 
942
\begin{frame}
 
943
  \frametitle{Evaluation}
 
944
  \framesubtitle{Chunks and Threads}
 
945
  \begin{itemize}
 
946
  \item eval-chunk (run code inside a code chunk)
 
947
  \item eval-thread (run code inside a series of code chunks)
 
948
  \end{itemize}
 
949
\end{frame}
 
950
 
 
951
\begin{frame}
 
952
  \frametitle{Accelerated Sweave Development }
 
953
  \begin{itemize}
 
954
  \item ESS has specialized support
 
955
  \item use Makefiles (editor-neutral approach)
 
956
  \item \textbf{M-x ess-makeSweave}    or \textbf{M-n s}
 
957
  \item \textbf{M-x ess-makeLatex}     or \textbf{M-n l}
 
958
  \item \textbf{M-x ess-makePS}        or \textbf{M-n p}  
 
959
  \item \textbf{M-x ess-makePDF}       or \textbf{M-n P}
 
960
  \item \textbf{M-x ess-insert-Sexpr}  or \textbf{M-n x}
 
961
  \end{itemize}
 
962
\end{frame}
 
963
 
 
964
\subsection{Review: ESS}
 
965
 
 
966
\begin{frame}
 
967
  \frametitle{Review: Using ESS}
 
968
  \begin{itemize}
 
969
  \item ESS for R has 4 modes: editing, interactive, transcript, help.
 
970
  \item Focus on learning to use keystrokes rather than mouse.
 
971
  \end{itemize}
 
972
\end{frame}
 
973
 
 
974
\section{Emacs is Extended}
 
975
 
 
976
\begin{frame}
 
977
  \frametitle{Packages and Extensions.}
 
978
  Emacs has many modes: 
 
979
  \begin{itemize}
 
980
  \item language-specific markup (programming, markup)
 
981
  \item editor behavior (spell checking, pending delete, folding,
 
982
    editor emulation (vi, brief))
 
983
  \item IDE capabilities (object explorers, completers)
 
984
  \item database (edb)
 
985
  \item communication (mail, news, www, rdf)
 
986
  \item sub (inferior) process control (telnet, R, \ldots)
 
987
  \item publication (text mode conversion)
 
988
  \item version control interfaces
 
989
  \item anything you can program!    
 
990
  \end{itemize}
 
991
\end{frame}
 
992
 
 
993
\begin{frame}
 
994
  \frametitle{Relevant to Data analysis and R}
 
995
  \begin{itemize}
 
996
  \item folding modes (outline; however, the newer version, allout,
 
997
    stomps on R-mode)
 
998
  \item object explorers (ecb)
 
999
  \item documentation modes
 
1000
    \begin{itemize}
 
1001
    \item specialized:  latex, html, rtf
 
1002
    \item generic: muse, \ldots (idea: simple markup which translates to
 
1003
      html, latex, texinfo, etc).
 
1004
    \end{itemize}
 
1005
  \end{itemize}
 
1006
\end{frame}
 
1007
 
 
1008
\begin{frame} 
 
1009
  \frametitle{Dired}
 
1010
  A directory/file explorer and navigator.
 
1011
\end{frame}
 
1012
 
 
1013
\begin{frame}
 
1014
  \frametitle{Emacs Code Browser}
 
1015
  \begin{itemize}
 
1016
  \item ESS integrates to support R
 
1017
  \item Extension/customization: through imenu support.
 
1018
  \item file-level navigation and objects, editing history of files,
 
1019
    files in current directory, directory tree.
 
1020
  \end{itemize}
 
1021
  (demo with R-examples/FCS.R)
 
1022
\end{frame}
 
1023
 
 
1024
\begin{frame}
 
1025
  \frametitle{Muse}
 
1026
  \framesubtitle{a mode for documentation and notes}
 
1027
  \begin{itemize}
 
1028
  \item Wiki-like editing, hyperlinks, within text.
 
1029
  \item simple format
 
1030
  \item Supports generation of latex, pdf, (x)html, xml.
 
1031
  \end{itemize}
 
1032
\end{frame}
 
1033
 
 
1034
\begin{frame}
 
1035
  \frametitle{Planner: Task management}
 
1036
  \framesubtitle{getting organized and tracking activity}
 
1037
  \begin{itemize}
 
1038
  \item Plain-text task management and organization
 
1039
  \item Supports many common time-management approaches (GTD, ).
 
1040
  \item Extremely customizeable
 
1041
  \end{itemize}
 
1042
\end{frame}
 
1043
 
 
1044
\subsection{LaTeX Extensions}
 
1045
 
 
1046
\begin{frame}
 
1047
  \frametitle{LaTeX Support}
 
1048
  \framesubtitle{nearly WYSIWYG}
 
1049
  \begin{itemize}
 
1050
  \item AUC-TeX: latex document support
 
1051
  \item BiBTeX-mode and RefTeX: citation management
 
1052
  \item X-Symbol: native display of mathematical symbols
 
1053
  \item tex-preview: You can see what you will get (YCSWYWG)
 
1054
  \end{itemize}
 
1055
\end{frame}
 
1056
 
 
1057
\section{Lisp and Emacs Lisp}
 
1058
 
 
1059
\begin{frame}
 
1060
  \frametitle{Customizing Emacs}
 
1061
  \framesubtitle{Sometimes with Lisp}
 
1062
  \begin{itemize}
 
1063
  \item Critical components for customizing Emacs: current best
 
1064
    practices suggest that you customize via ``M-x customize''. (this
 
1065
    is a recent (last 5 years) change!).
 
1066
  \item However, adding Lisp commands to your \textbf{.emacs} file is 
 
1067
    still very useful (and sometimes required).
 
1068
  \item Note that commas denote comments (from the comma until the end
 
1069
    of the line).
 
1070
  \end{itemize}
 
1071
\end{frame}
 
1072
 
 
1073
\subsection{Introduction to Lisp}
 
1074
 
 
1075
\begin{frame}[fragile]
 
1076
  \frametitle{Lisp}
 
1077
  Lisp (LISt Processor) is different than most high-level computing
 
1078
  languages, and similar to Emacs, it is very old (1956).  Lisp is
 
1079
  built on lists of things which might be evaluated:
 
1080
\begin{verbatim}
 
1081
(function data1 data2 data3)
 
1082
\end{verbatim}
 
1083
  or ``quoted'':
 
1084
\begin{verbatim}
 
1085
'(function data1 data2 data3)
 
1086
\end{verbatim}
 
1087
  The difference is important -- lists of data (the second) are not
 
1088
  functions applied to data (the first).
 
1089
\end{frame}
 
1090
 
 
1091
\begin{frame}[fragile]
 
1092
  \frametitle{Evaluation}
 
1093
  Lisp is built on lists of things which might be evaluated:
 
1094
\begin{verbatim}
 
1095
(function data1 data2 data3)
 
1096
\end{verbatim}
 
1097
  or ``quoted'':
 
1098
\begin{verbatim}
 
1099
'(function data1 data2 data3)
 
1100
(list function data1 data2 data3)
 
1101
\end{verbatim}
 
1102
  The difference is important -- lists of data (the second) are not
 
1103
  functions applied to data (the first).
 
1104
\end{frame}
 
1105
 
 
1106
\begin{frame}[fragile]
 
1107
  \frametitle{Defining Variables}
 
1108
  \framesubtitle{Setting variables}
 
1109
\begin{verbatim}
 
1110
(setq <variable> <value>)
 
1111
\end{verbatim}
 
1112
  Example:
 
1113
\begin{verbatim}
 
1114
(setq ess-source-directory
 
1115
      "/home/rossini/R-src")
 
1116
\end{verbatim}
 
1117
\end{frame}
 
1118
 
 
1119
\begin{frame}[fragile]
 
1120
  \frametitle{Defining on the fly}
 
1121
\begin{verbatim}
 
1122
(setq ess-source-directory
 
1123
   (lambda () (file-name-as-directory
 
1124
         (expand-file-name
 
1125
           (concat (default-directory)
 
1126
                   ess-suffix "-src")))))
 
1127
\end{verbatim}
 
1128
  (Lambda-expressions are anonymous functions, i.e. ``instant-functions'') 
 
1129
\end{frame}
 
1130
 
 
1131
 
 
1132
\begin{frame}[fragile]
 
1133
  \frametitle{Function Reuse}
 
1134
  By naming the function, we could make the previous example reusable
 
1135
  (if possible):
 
1136
\begin{verbatim}
 
1137
(defun my-src-directory ()
 
1138
      (file-name-as-directory
 
1139
         (expand-file-name
 
1140
           (concat (default-directory)
 
1141
                   ess-suffix "-src"))))
 
1142
\end{verbatim}
 
1143
  Example:
 
1144
\begin{verbatim}
 
1145
(setq ess-source-directory (my-src-directory))
 
1146
\end{verbatim}
 
1147
\end{frame}
 
1148
 
 
1149
\begin{frame}[fragile]
 
1150
  \frametitle{Programming Emacs Lisp} 
 
1151
 
 
1152
  There are three general approaches to testing, evaluating, and
 
1153
  deploying Emacs Lisp code.
 
1154
  \begin{itemize}
 
1155
  \item Loading files:  \verb+M-x load-file <filename.el>+
 
1156
  \item Using the \verb+*scratch*+ buffer
 
1157
  \item \verb+ielm+ , an emacs-lisp REPL
 
1158
  \end{itemize}
 
1159
  Review the latter two
 
1160
\end{frame}
 
1161
 
 
1162
\begin{frame}[fragile]
 
1163
  \frametitle{Playing in the scratch buffer.}
 
1164
  \begin{enumerate}
 
1165
  \item \verb+C-x b *scratch*+
 
1166
  \item (display-time)\verb+C-j+
 
1167
  \item (setq my-test ``asdf'')\verb+C-j+
 
1168
  \item my-test\verb+C-j+
 
1169
  \end{enumerate}
 
1170
\end{frame}
 
1171
 
 
1172
\begin{frame}
 
1173
  \frametitle{ielm: command-line usage.}
 
1174
  \begin{enumerate}
 
1175
  \item M-x ielm
 
1176
  \item follow the instructions for more information (similar to using
 
1177
    R in interactive mode)
 
1178
  \end{enumerate}
 
1179
\end{frame}
 
1180
 
 
1181
\subsection{Extending Emacs and ESS}
 
1182
 
 
1183
\begin{frame}
 
1184
  \frametitle{Organization.}
 
1185
  \framesubtitle{Structure of ESS}
 
1186
  \begin{itemize}
 
1187
  \item How ESS works
 
1188
  \item Reading the code
 
1189
  \item making extensions
 
1190
  \end{itemize}
 
1191
\end{frame}
 
1192
 
 
1193
\begin{frame}
 
1194
  \frametitle{Debugging.}
 
1195
  \begin{itemize}
 
1196
  \item Set options to ``debug on error'' and ``debug on signal''.
 
1197
    Both bring up the stack-trace of the current status of the lisp
 
1198
    program (nesting and variable values).
 
1199
  \item Look for errors in loading to determine the path taken to the error
 
1200
  \item more sophisticated debuggers exist.
 
1201
  \end{itemize}
 
1202
\end{frame}
 
1203
 
 
1204
 
 
1205
\begin{frame}
 
1206
  \frametitle{Idea generation: SLIME}
 
1207
  \framesubtitle{Lisp IDE suggests ESS improvements}
 
1208
  \begin{itemize}
 
1209
  \item Use R subprocesses (old idea of DTL).
 
1210
  \item Synchronize processes
 
1211
  \end{itemize}
 
1212
\end{frame}
 
1213
 
 
1214
 
 
1215
\section{Discussion}
 
1216
 
 
1217
\begin{frame}
 
1218
  \frametitle{Future?}
 
1219
  \begin{itemize}
 
1220
  \item Continued support for R within ESS
 
1221
  \item Object and formating support
 
1222
  \end{itemize}
 
1223
\end{frame}
 
1224
 
 
1225
 
 
1226
\begin{frame}
 
1227
  \frametitle<presentation>{Summary}
 
1228
 
 
1229
  % Keep the summary *very short*.
 
1230
  \begin{itemize}
 
1231
  \item
 
1232
    Emacs takes time to learn, but rewards the user.
 
1233
  \item
 
1234
    ESS enhances R.
 
1235
  \item
 
1236
    Lisp is worth learning.
 
1237
  \end{itemize}
 
1238
  
 
1239
  % The following outlook is optional.
 
1240
  \vskip0pt plus.5fill
 
1241
  \begin{itemize}
 
1242
  \item
 
1243
    Outlook
 
1244
    \begin{itemize}
 
1245
    \item
 
1246
      ESS is the oldest open-source statistics project; yet it can
 
1247
      always be improved!
 
1248
    \item
 
1249
      Many possible extensions for supporting work modes for
 
1250
      Statisticians and Data Analysts.  More need implementation.
 
1251
    \end{itemize}
 
1252
  \end{itemize}
 
1253
\end{frame}
 
1254
 
 
1255
\end{document}