The R Project SVN R

Rev

Rev 8280 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8280 Rev 8384
Line 1... Line 1...
1
R FAQ
1
R FAQ
2
Frequently Asked Questions on R
2
Frequently Asked Questions on R
3
Version 0.99-4, 2000/02/20
3
Version 1.0-0, 2000/02/27
4
Kurt Hornik
4
Kurt Hornik
5
 
5
 
6
 
6
 
7
Table of Contents
7
Table of Contents
8
*****************
8
*****************
Line 65... Line 65...
65
  7.8 How does autoloading work?
65
  7.8 How does autoloading work?
66
  7.9 How should I set options?
66
  7.9 How should I set options?
67
  7.10 How do file names work in Windows?
67
  7.10 How do file names work in Windows?
68
  7.11 Why does plotting give a color allocation error?
68
  7.11 Why does plotting give a color allocation error?
69
  7.12 Is R Y2K-compliant?
69
  7.12 Is R Y2K-compliant?
-
 
70
  7.13 How do I convert factors to numeric?
70
 
71
 
71
8 R Programming
72
8 R Programming
72
  8.1 How should I write summary methods?
73
  8.1 How should I write summary methods?
73
  8.2 How can I debug dynamically loaded code?
74
  8.2 How can I debug dynamically loaded code?
74
  8.3 How can I inspect R objects when debugging?
75
  8.3 How can I inspect R objects when debugging?
Line 124... Line 125...
124
site (*Note What is CRAN?::).
125
site (*Note What is CRAN?::).
125
 
126
 
126
1.3 Citing this document
127
1.3 Citing this document
127
========================
128
========================
128
 
129
 
129
   In publications, please refer to this FAQ as Hornik (1999), "The R FAQ"
130
   In publications, please refer to this FAQ as Hornik (2000), "The R FAQ"
130
and give the above, _official_ URL.
131
and give the above, _official_ URL.
131
 
132
 
132
1.4 Notation
133
1.4 Notation
133
============
134
============
134
 
135
 
Line 176... Line 177...
176
modify the R source code CVS archive.  The group currently consists of Doug
177
modify the R source code CVS archive.  The group currently consists of Doug
177
Bates, Peter Dalgaard, Robert Gentleman, Kurt Hornik, Ross Ihaka, Friedrich
178
Bates, Peter Dalgaard, Robert Gentleman, Kurt Hornik, Ross Ihaka, Friedrich
178
Leisch, Thomas Lumley, Martin Maechler, Guido Masarotto, Paul Murrell,
179
Leisch, Thomas Lumley, Martin Maechler, Guido Masarotto, Paul Murrell,
179
Brian Ripley, Duncan Temple Lang, and Luke Tierney.
180
Brian Ripley, Duncan Temple Lang, and Luke Tierney.
180
 
181
 
181
   R has a home page at `http://stat.auckland.ac.nz/r/r.html'.  It is free
182
   R has a home page at `http://www.r-project.org/'.  It is free software
182
software distributed under a GNU-style copyleft, and an official part of
183
distributed under a GNU-style copyleft, and an official part of the GNU
183
the GNU project ("GNU S").
184
project ("GNU S").
184
 
185
 
185
2.2 What machines does R run on?
186
2.2 What machines does R run on?
186
================================
187
================================
187
 
188
 
188
   R is being developed for the Unix, Windows and Mac families of operating
189
   R is being developed for the Unix, Windows and Mac families of operating
Line 196... Line 197...
196
   If you know about other platforms, please drop us a note.
197
   If you know about other platforms, please drop us a note.
197
 
198
 
198
2.3 What is the current version of R?
199
2.3 What is the current version of R?
199
=====================================
200
=====================================
200
 
201
 
201
   The current stable Unix/Windows version is 0.99.0, the unstable one is
202
   The current stable Unix/Windows version is 1.0.0, the unstable one is
202
1.0.0.  Typically, new features are introduced in the development versions;
203
1.1.0.  Typically, new features are introduced in the development versions;
203
updates of stable versions are for bug fixes mostly.  The version for the
204
updates of stable versions are for bug fixes mostly.  The version for the
204
Mac is pre-alpha.
205
Mac is pre-alpha.
205
 
206
 
206
   The release of version 1.0 is scheduled for February 29, 2000.
-
 
207
 
-
 
208
2.4 How can R be obtained?
207
2.4 How can R be obtained?
209
==========================
208
==========================
210
 
209
 
211
   Sources, binaries and documentation for R can be obtained via CRAN, the
210
   Sources, binaries and documentation for R can be obtained via CRAN, the
212
"Comprehensive R Archive Network" (see *Note What is CRAN?::).
211
"Comprehensive R Archive Network" (see *Note What is CRAN?::).
213
 
212
 
-
 
213
   Sources are also available via anonymous rsync.  Use
-
 
214
 
-
 
215
     rsync -rC rsync.r-project.org::MODULE R
-
 
216
 
-
 
217
to create a copy of the source tree specified by MODULE in the subdirectory
-
 
218
`R' of the current directory, where MODULE specifies one of the three
-
 
219
existing flavors of the R sources, and can be one of `r-release' (latest
-
 
220
released version), `r-release-patched' (latest released version with
-
 
221
patches applied), and `r-devel' (current development version).  The rsync
-
 
222
trees are created directly from the master CVS archive and are updated
-
 
223
hourly.  The `-C' option in the rsync command is to cause it to skip the
-
 
224
CVS directories.  Further information on rsync is available at
-
 
225
`http://rsync.samba.org/rsync/'.
-
 
226
 
214
2.5 How can R be installed?
227
2.5 How can R be installed?
215
===========================
228
===========================
216
 
229
 
217
2.5.1 How can R be installed (Unix)
230
2.5.1 How can R be installed (Unix)
218
-----------------------------------
231
-----------------------------------
Line 229... Line 242...
229
   Note that you need a FORTRAN compiler or `f2c' in addition to a C
242
   Note that you need a FORTRAN compiler or `f2c' in addition to a C
230
compiler to build R.  Also, you need Perl version 5 to build the R object
243
compiler to build R.  Also, you need Perl version 5 to build the R object
231
documentations.  (If this is not available on your system, you can obtain a
244
documentations.  (If this is not available on your system, you can obtain a
232
PDF version of the object reference manual via CRAN.)
245
PDF version of the object reference manual via CRAN.)
233
 
246
 
234
   In the simplest case, untar the R source code, cd to the directory thus
247
   In the simplest case, untar the R source code, change to the directory
235
created, and issue the following commands (at the shell prompt):
248
thus created, and issue the following commands (at the shell prompt):
236
 
249
 
237
     $ ./configure
250
     $ ./configure
238
     $ make
251
     $ make
239
 
252
 
240
   If these commands execute successfully, the R binary and a shell script
253
   If these commands execute successfully, the R binary and a shell script
Line 248... Line 261...
248
Extension Writers Guide", in the `doc/manual' subdirectory.  These files
261
Extension Writers Guide", in the `doc/manual' subdirectory.  These files
249
can be previewed and printed using standard programs such as `xdvi' and
262
can be previewed and printed using standard programs such as `xdvi' and
250
`dvips'.  You can also use `make pdf' to build PDF (Portable Document
263
`dvips'.  You can also use `make pdf' to build PDF (Portable Document
251
Format) version of the manuals, and view these using Acrobat.  Manuals
264
Format) version of the manuals, and view these using Acrobat.  Manuals
252
written in the GNU Texinfo system can also be converted to info files
265
written in the GNU Texinfo system can also be converted to info files
253
suitable for reading online with Emacs or standalone GNU Info; use `make
266
suitable for reading online with Emacs or stand-alone GNU Info; use `make
254
info' to create these versions (note that this requires `makeinfo' version
267
info' to create these versions (note that this requires `makeinfo' version
255
4).
268
4).
256
 
269
 
257
   Finally, use `make check' to find out whether your R system works
270
   Finally, use `make check' to find out whether your R system works
258
correctly.
271
correctly.
Line 264... Line 277...
264
     (some) executables
277
     (some) executables
265
 
278
 
266
`${prefix}/man/man1'
279
`${prefix}/man/man1'
267
     man pages
280
     man pages
268
 
281
 
269
`${prefix}/share/R'
282
`${prefix}/lib/R'
270
     all the rest (libraries, on-line help system, ...).  This is the "R
283
     all the rest (libraries, on-line help system, ...).  This is the "R
271
     Home Directory" (`R_HOME') of the installed system.
284
     Home Directory" (`R_HOME') of the installed system.
272
 
285
 
273
In the above, `prefix' is determined during configuration (typically
286
In the above, `prefix' is determined during configuration (typically
274
`/usr/local') and can be set by running `configure' with the option
287
`/usr/local') and can be set by running `configure' with the option
Line 305... Line 318...
305
distribution is available.  We hope that this will change soon.
318
distribution is available.  We hope that this will change soon.
306
 
319
 
307
2.6 Are there Unix binaries for R?
320
2.6 Are there Unix binaries for R?
308
==================================
321
==================================
309
 
322
 
310
   The `bin/linux' directory contains Debian 2.1 and 2.2 packages for the
323
   The `bin/linux' directory of a CRAN site contains Debian 2.1 and 2.2
311
i386 platform (now part of the Debian distribution and maintained by Doug
324
packages for the i386 platform (now part of the Debian distribution and
312
Bates), Red Hat 6.x packages for the alpha, i386 and sparc platforms
325
maintained by Doug Bates), Red Hat 6.x packages for the alpha, i386 and
313
(maintained by Naoki Takebayashi, Martyn Plummer, and Vin Everett,
326
sparc platforms (maintained by Naoki Takebayashi, Martyn Plummer, and Vin
314
respectively), SuSE 5.3/6.0/6.2/6.3 i386 packages by Albrecht Gebhardt, and
327
Everett, respectively), SuSE 5.3/6.0/6.2/6.3 i386 packages by Albrecht
315
Linuxppc 5.0 RPMs by Alex Buerkle.
328
Gebhardt, and Linuxppc 5.0 RPMs by Alex Buerkle.
316
 
329
 
317
   The `bin/osf' directory contains RPMs for alpha systems running Digital
330
   The `bin/osf' directory of a CRAN site contains RPMs for alpha systems
318
Unix 4.0 by Albrecht Gebhardt.
331
running Digital Unix 4.0 by Albrecht Gebhardt.
319
 
332
 
320
   No other binary distributions have thus far been made publically
333
   No other binary distributions have thus far been made publically
321
available.
334
available.
322
 
335
 
323
2.7 What documentation exists for R?
336
2.7 What documentation exists for R?
Line 332... Line 345...
332
   This documentation can also be made available as one reference manual
345
   This documentation can also be made available as one reference manual
333
for on-line reading in HTML and PDF formats, and as hardcopy via LaTeX, see
346
for on-line reading in HTML and PDF formats, and as hardcopy via LaTeX, see
334
*Note How can R be installed?::.  An up-to-date HTML version is always
347
*Note How can R be installed?::.  An up-to-date HTML version is always
335
available for web browsing at `http://stat.ethz.ch/R/manual/'.
348
available for web browsing at `http://stat.ethz.ch/R/manual/'.
336
 
349
 
337
   Currently, three further R manuals are being written:
350
   The R distribution also comes with the following manuals.
338
 
351
 
339
   * "An Introduction to R" (`R-intro') includes information on data types,
352
   * "An Introduction to R" (`R-intro') includes information on data types,
340
     programming elements, statistical modelling and graphics.  This
353
     programming elements, statistical modeling and graphics.  This
341
     document is based on the "Notes on S-PLUS" by Bill Venables and David
354
     document is based on the "Notes on S-PLUS" by Bill Venables and David
342
     Smith.
355
     Smith.
343
 
356
 
344
   * "R Language Definition" (`R-lang') is the "Kernighan & Ritchie of R",
-
 
345
     explaining evaluation, parsing, object oriented programming, computing
-
 
346
     on the language, and so forth.
-
 
347
 
-
 
348
   * "Writing R Extensions" (`R-exts') currently desribes the process of
357
   * "Writing R Extensions" (`R-exts') currently describes the process of
349
     creating R add-on packages, writing R documentation, R's system and
358
     creating R add-on packages, writing R documentation, R's system and
350
     foreign language interfaces, and the R API.
359
     foreign language interfaces, and the R API.
351
 
360
 
-
 
361
Furthermore, the "R Language Definition" manual (`R-lang') is currently
352
The "R Language Definition" will be available for the 1.0 release, the
362
being written, and will be available in R version 1.2.  This is the
-
 
363
"Kernighan & Ritchie of R", explaining evaluation, parsing, object oriented
353
other two already come with R.
364
programming, computing on the language, and so forth.
354
 
365
 
355
   In addition to material written specifically for R, documentation for
366
   In addition to material written specifically for R, documentation for
356
S/S-PLUS (see *Note R and S::) can be used in combination with this FAQ
367
S/S-PLUS (see *Note R and S::) can be used in combination with this FAQ
357
(*note What are the differences between R and S?::).  We recommend
368
(*note What are the differences between R and S?::).  We recommend
358
 
369
 
359
     W. N. Venables and B. D. Ripley (1999), "Modern Applied Statistics with
370
     W. N. Venables and B. D. Ripley (1999), "Modern Applied Statistics with
360
     S-PLUS.  Third Edition".  Springer, ISBN 0-387-98825-4.
371
     S-PLUS.  Third Edition".  Springer, ISBN 0-387-98825-4.
361
 
372
 
362
which has a home page at `http://www.stats.ox.ac.uk/pub/MASS3/' providing
373
This has a home page at `http://www.stats.ox.ac.uk/pub/MASS3/' providing
363
additional material, in particular "R Complements" which describe how to
374
additional material, in particular "R Complements" which describe how to
364
use the book with R.  These complements provide both descriptions of some
375
use the book with R.  These complements provide both descriptions of some
365
of the differences between R and S-PLUS, and the modifications needed to
376
of the differences between R and S-PLUS, and the modifications needed to
366
run the examples in the book.  Its companion volume on "S Programming", due
377
run the examples in the book.  Its companion volume on "S Programming", due
367
in about April 2000, will provide an in-depth guide to writing software in
378
in about April 2000, will provide an in-depth guide to writing software in
Line 476... Line 487...
476
operating systems (Linux, Digital Unix, and MS Windows).  CRAN also
487
operating systems (Linux, Digital Unix, and MS Windows).  CRAN also
477
provides access to documentation on R, existing mailing lists and the R Bug
488
provides access to documentation on R, existing mailing lists and the R Bug
478
Tracking system.
489
Tracking system.
479
 
490
 
480
   To "submit" to CRAN, simply upload to
491
   To "submit" to CRAN, simply upload to
481
`ftp://cran.r-project.org/incoming' and send an email to
492
`ftp://cran.r-project.org/incoming/' and send an email to
482
<wwwadmin@cran.r-project.org>.
493
<wwwadmin@cran.r-project.org>.
483
 
494
 
484
     *Note:*  It is very important that you indicate the copyright
495
     *Note:*  It is very important that you indicate the copyright
485
     (license) information (GPL, BSD, Artistic, ...) in your submission.
496
     (license) information (GPL, BSD, Artistic, ...) in your submission.
486
 
497
 
Line 512... Line 523...
512
improve its usefulness at every stage of the programming process, is
523
improve its usefulness at every stage of the programming process, is
513
described in "Programming with Data"
524
described in "Programming with Data"
514
(http://cm.bell-labs.com/cm/ms/departments/sia/Sbook/) by John M. Chambers
525
(http://cm.bell-labs.com/cm/ms/departments/sia/Sbook/) by John M. Chambers
515
(1998), Springer: New York, ISBN 0-387-98503-4.
526
(1998), Springer: New York, ISBN 0-387-98503-4.
516
 
527
 
517
   In 1998, the Association for Computing Machinery presented its Software
528
   In 1998, the Association for Computing Machinery (ACM) presented its
518
System Award to John Chambers for the design of the S system. The ACM
529
Software System Award to John Chambers for the design of the S system.  The
519
citation stated that "S has forever altered the way people analyze,
530
ACM citation stated that "S has forever altered the way people analyze,
520
visualize, and manipulate data .... S is an elegant, widely accepted, and
531
visualize, and manipulate data ....  S is an elegant, widely accepted, and
521
enduring software system, with conceptual integrity, thanks to the insight,
532
enduring software system, with conceptual integrity, thanks to the insight,
522
taste, and effort of John Chambers."  See
533
taste, and effort of John Chambers."  See
523
`http://netlib.bell-labs.com/cm/ms/departments/sia/S/index.html' for
534
`http://cm.bell-labs.com/cm/ms/departments/sia/S/history.html' for "Stages
524
"Stages in the Evolution of S".
535
in the Evolution of S".
525
 
536
 
526
   There is a huge amount of user-contributed code for S, available at the
537
   There is a huge amount of user-contributed code for S, available at the
527
S Repository (http://lib.stat.cmu.edu) at CMU.
538
S Repository (http://lib.stat.cmu.edu/S/) at CMU.
528
 
539
 
529
   The "Frequently Asked Questions about S" (http://lib.stat.cmu.edu/S/faq)
540
   The "Frequently Asked Questions about S" (http://lib.stat.cmu.edu/S/faq)
530
contains further information about S, but is not up-to-date.
541
contains further information about S, but is not up-to-date.
531
 
542
 
532
3.2 What is S-PLUS?
543
3.2 What is S-PLUS?
Line 691... Line 702...
691
state.  A simple example (taken from Abelson and Sussman) is obtained by
702
state.  A simple example (taken from Abelson and Sussman) is obtained by
692
typing `demo(scoping)' at the R prompt.  Further information is provided in
703
typing `demo(scoping)' at the R prompt.  Further information is provided in
693
the standard R reference "R: A Language for Data Analysis and Graphics"
704
the standard R reference "R: A Language for Data Analysis and Graphics"
694
(*note What documentation exists for R?::) and a paper on "Lexical Scope
705
(*note What documentation exists for R?::) and a paper on "Lexical Scope
695
and Statistical Computing" by Robert Gentleman and Ross Ihaka which can be
706
and Statistical Computing" by Robert Gentleman and Ross Ihaka which can be
696
obtained from the `doc/misc' directory of a CRAN site and will appear in
707
obtained from the `doc/misc' directory of a CRAN site and will appear in the
697
the _Journal of Computational and Graphical Statistics_ around the
708
_Journal of Computational and Graphical Statistics_ around the beginning of
698
beginning of 2000.
709
2000.
699
 
710
 
700
   Lexical scoping also implies a further major difference.  Whereas S
711
   Lexical scoping also implies a further major difference.  Whereas S
701
stores all objects as separate files in a directory somewhere (usually
712
stores all objects as separate files in a directory somewhere (usually
702
`.Data' under the current directory), R does not.  All objects in R are
713
`.Data' under the current directory), R does not.  All objects in R are
703
stored internally.  When R is started up it grabs a very large piece of
714
stored internally.  When R is started up it grabs a very large piece of
Line 712... Line 723...
712
and data stored in R's internal memory at any time) can be a bit slow,
723
and data stored in R's internal memory at any time) can be a bit slow,
713
especially if they are big.  In S this does not happen, because everything
724
especially if they are big.  In S this does not happen, because everything
714
is saved in disk files and if you crash nothing is likely to happen to
725
is saved in disk files and if you crash nothing is likely to happen to
715
them.  (In fact, one might conjecture that the S developers felt that the
726
them.  (In fact, one might conjecture that the S developers felt that the
716
price of changing their approach to persistent storage just to accommodate
727
price of changing their approach to persistent storage just to accommodate
717
lexical scope was far too expensive.)  R is still in a beta stage, and may
728
lexical scope was far too expensive.)  Hence, when doing important work,
718
crash from time to time.  Hence, for important work you should consider
729
you might consider saving often (see *Note How can I save my workspace?::)
719
saving often (see *Note How can I save my workspace?::).  Other
730
to safeguard against possible crashes.  Other possibilities are logging
720
possibilities are logging your sessions, or have your R commands stored in
731
your sessions, or have your R commands stored in text files which can be
721
text files which can be read in using `source()'.
732
read in using `source()'.
722
 
733
 
723
     *Note:*  If you run R from within Emacs (see *Note R and Emacs::), you
734
     *Note:*  If you run R from within Emacs (see *Note R and Emacs::), you
724
     can save the contents of the interaction buffer to a file and
735
     can save the contents of the interaction buffer to a file and
725
     conveniently manipulate it using `ess-transcript-mode', as well as
736
     conveniently manipulate it using `ess-transcript-mode', as well as
726
     save source copies of all functions and data used.
737
     save source copies of all functions and data used.
Line 736... Line 747...
736
 
747
 
737
   * The glm family objects are implemented differently in R and S.  The
748
   * The glm family objects are implemented differently in R and S.  The
738
     same functionality is available but the components have different
749
     same functionality is available but the components have different
739
     names.
750
     names.
740
 
751
 
-
 
752
   * Option `na.action' is set to `"na.omit"' by default in R, but not set
-
 
753
     in S.
-
 
754
 
741
   * Terms objects are stored differently.  In S a terms object is an
755
   * Terms objects are stored differently.  In S a terms object is an
742
     expression with attributes, in R it is a formula with attributes.  The
756
     expression with attributes, in R it is a formula with attributes.  The
743
     attributes have the same names but are mostly stored differently.  The
757
     attributes have the same names but are mostly stored differently.  The
744
     major difference in functionality is that a terms object is
758
     major difference in functionality is that a terms object is
745
     subscriptable in S but not in R.  If you can't imagine why this would
759
     subscriptable in S but not in R.  If you can't imagine why this would
Line 784... Line 798...
784
     appropriate startup profiles.
798
     appropriate startup profiles.
785
 
799
 
786
   * In R, `T' and `F' are just variables being set to `TRUE' and `FALSE',
800
   * In R, `T' and `F' are just variables being set to `TRUE' and `FALSE',
787
     respectively, but are not reserved words as in S and hence can be
801
     respectively, but are not reserved words as in S and hence can be
788
     overwritten by the user.  (This helps e.g. when you have factors with
802
     overwritten by the user.  (This helps e.g. when you have factors with
789
     levels "T" or "F".)  Hence, when writing code you should always use
803
     levels `"T"' or `"F"'.)  Hence, when writing code you should always
790
     `TRUE' and `FALSE'.
804
     use `TRUE' and `FALSE'.
791
 
805
 
792
   * In R, `dyn.load()' can only load _shared libraries_, as created for
806
   * In R, `dyn.load()' can only load _shared libraries_, as created for
793
     example by `R SHLIB'.
807
     example by `R SHLIB'.
794
 
808
 
795
   * In R, `attach()' currently only works for lists and data frames (not
809
   * In R, `attach()' currently only works for lists and data frames (not
Line 844... Line 858...
844
 
858
 
845
   * In S, `substitute()' searches for names for substitution in the given
859
   * In S, `substitute()' searches for names for substitution in the given
846
     expression in three places: the actual and the default arguments of
860
     expression in three places: the actual and the default arguments of
847
     the matching call, and the local frame (in that order).  R looks in
861
     the matching call, and the local frame (in that order).  R looks in
848
     the local frame only, with the special rule to use a "promise" if a
862
     the local frame only, with the special rule to use a "promise" if a
849
     variable is not evaluated. Since the local frame is initialized with
863
     variable is not evaluated.  Since the local frame is initialized with
850
     the actual arguments or the default expressions, this is usually
864
     the actual arguments or the default expressions, this is usually
851
     equivalent to S, until assignment takes place.
865
     equivalent to S, until assignment takes place.
852
 
866
 
853
   * In R, `eval(EXPR, sys.parent())' does not work.  Instead, one should
867
   * In R, `eval(EXPR, sys.parent())' does not work.  Instead, one should
854
     use `eval(EXPR, sys.frame(sys.parent())),' which also works in S.
868
     use `eval(EXPR, sys.frame(sys.parent())),' which also works in S.
Line 876... Line 890...
876
scoping may simplify matters considerably, though.)
890
scoping may simplify matters considerably, though.)
877
 
891
 
878
   R offers several graphics features that S-PLUS does not, such as finer
892
   R offers several graphics features that S-PLUS does not, such as finer
879
handling of line types, more convenient color handling (via palettes),
893
handling of line types, more convenient color handling (via palettes),
880
gamma correction for color, and, most importantly, mathematical annotation
894
gamma correction for color, and, most importantly, mathematical annotation
881
in plot texts, via input expressions reminiscent of TeX constructs.
895
in plot texts, via input expressions reminiscent of TeX constructs.  See
882
Unfortunately, this feature still is mostly undocumented.  The paper "An
896
the help page for `plotmath', which features an impressive on-line example.
883
Approach to Providing Mathematical Annotation in Plots" by Paul Murrell and
897
The paper "An Approach to Providing Mathematical Annotation in Plots" by
884
Ross Ihaka, which will soon appear in the _Journal of Computational and
898
Paul Murrell and Ross Ihaka, which will soon appear in the _Journal of
885
Graphical Statistics_, has more details on this.
899
Computational and Graphical Statistics_, has more details on this.
886
 
900
 
887
4 R Web Interfaces
901
4 R Web Interfaces
888
******************
902
******************
889
 
903
 
890
   *Rcgi* is a CGI WWW interface to R by Mark J Ray <h089@mth.uea.ac.uk>.
904
   *Rcgi* is a CGI WWW interface to R by Mark J. Ray <h089@mth.uea.ac.uk>.
891
Recent version have the ability to use "embedded code": you can mix user
905
Recent versions have the ability to use "embedded code": you can mix user
892
input and code, allowing the HTML author to do anything from load in data
906
input and code, allowing the HTML author to do anything from load in data
893
sets to enter most of the commands for users without writing CGI scripts.
907
sets to enter most of the commands for users without writing CGI scripts.
894
Graphical output is possible in PostScript or GIF formats and the executed
908
Graphical output is possible in PostScript or GIF formats and the executed
895
code is presented to the user for revision.
909
code is presented to the user for revision.
896
 
910
 
897
   Demo and download are available from
911
   Demo and download are available from
898
`http://www.mth.uea.ac.uk/~h089/Rcgi/'.
912
`http://www.mth.uea.ac.uk/~h089/Rcgi/'.
899
 
913
 
900
   *Rweb* is developed and maintained by Jeff Banfield
914
   *Rweb* is developed and maintained by Jeff Banfield
901
<jeff@math.montana.edu>.  The Rweb Home Page
915
<jeff@math.montana.edu>.  The Rweb Home Page
902
(http://www.math.montana.edu/Rweb) provides access to all three versions of
916
(http://www.math.montana.edu/Rweb/) provides access to all three versions
903
Rweb--a simple text entry form that returns output and graphs, a more
917
of Rweb--a simple text entry form that returns output and graphs, a more
904
sophisticated Javascript version that provides a multiple window
918
sophisticated Javascript version that provides a multiple window
905
environment, and a set of point and click modules that are useful for
919
environment, and a set of point and click modules that are useful for
906
introductory statistics courses and require no knowledge of the R language.
920
introductory statistics courses and require no knowledge of the R language.
907
All of the Rweb versions can analyze Web accessible datasets if a URL is
921
All of the Rweb versions can analyze Web accessible datasets if a URL is
908
provided.
922
provided.
909
 
923
 
910
   A paper on Rweb, providing a detailed explanation of the different
924
   The paper "Rweb: Web-based Statistical Analysis", providing a detailed
911
versions of Rweb and an overview of how Rweb works, was published in the
925
explanation of the different versions of Rweb and an overview of how Rweb
912
Journal of Statistical Software
926
works, was published in the Journal of Statistical Software
913
(`http://www.stat.ucla.edu/journals/jss/v04/i01').
927
(`http://www.stat.ucla.edu/journals/jss/v04/i01/').
914
 
928
 
915
5 R Add-On Packages
929
5 R Add-On Packages
916
*******************
930
*******************
917
 
931
 
918
5.1 Which add-on packages exist for R?
932
5.1 Which add-on packages exist for R?
919
======================================
933
======================================
920
 
934
 
921
   The R distribution comes with the following extra packages:
935
   The R distribution comes with the following extra packages:
922
 
936
 
923
*ctest*
937
*ctest*
924
     A collection of classical tests, including the Bartlett, Fisher,
938
     A collection of Classical TESTs, including the Bartlett, Fisher,
925
     Kruskal-Wallis, Kolmogorov-Smirnov, and Wilcoxon tests.
939
     Kruskal-Wallis, Kolmogorov-Smirnov, and Wilcoxon tests.
926
 
940
 
927
*eda*
941
*eda*
928
     Exploratory Data Analysis.  Currently only contains functions for
942
     Exploratory Data Analysis.  Currently only contains functions for
929
     robust line fitting, and median polish and smoothing.
943
     robust line fitting, and median polish and smoothing.
Line 944... Line 958...
944
 
958
 
945
*splines*
959
*splines*
946
     Regression spline functions and classes.
960
     Regression spline functions and classes.
947
 
961
 
948
*stepfun*
962
*stepfun*
949
     Code for dealing with step functions, including empirical cumulative
963
     Code for dealing with STEP FUNctions, including empirical cumulative
950
     distribution functions.
964
     distribution functions.
951
 
965
 
952
*ts*
966
*ts*
953
     Time series.
967
     Time Series.
954
 
968
 
955
   The following packages are available from the CRAN `src/contrib' area.
969
   The following packages are available from the CRAN `src/contrib' area.
956
 
970
 
957
*Devore5*
971
*Devore5*
958
     Data sets and sample analyses from "Probability and Statistics for
972
     Data sets and sample analyses from "Probability and Statistics for
959
     Engineering and the Sciences (5th ed)" by Jay L. Devore , 2000,
973
     Engineering and the Sciences (5th ed)" by Jay L. Devore, 2000, Duxbury.
960
     Duxbury.
-
 
961
 
974
 
962
*KernSmooth*
975
*KernSmooth*
963
     Functions for kernel smoothing (and density estimation) corresponding
976
     Functions for kernel smoothing (and density estimation) corresponding
964
     to the book "Kernel Smoothing" by M. P. Wand and M. C. Jones, 1995.
977
     to the book "Kernel Smoothing" by M. P. Wand and M. C. Jones, 1995.
965
 
978
 
966
*MASS*
979
*MASS*
967
     Functions and datasets from the main library of Venables and Ripley,
980
     Functions and datasets from the main package of Venables and Ripley,
968
     "Modern Applied Statistics with S-PLUS".  Contained in the `VR' bundle.
981
     "Modern Applied Statistics with S-PLUS".  Contained in the `VR' bundle.
969
 
982
 
970
*NISTnls*
983
*NISTnls*
971
     A set of test nonlinear least squares examples from NIST, the U.S.
984
     A set of test nonlinear least squares examples from NIST, the U.S.
972
     National Institute for Standards and Technology.
985
     National Institute for Standards and Technology.
973
 
986
 
974
*RmSQL*
987
*RmSQL*
975
     An interface between R and the mSQL database system.
988
     An interface between R and the mSQL database system.
976
 
989
 
977
*Rnotes*
990
*Rnotes*
978
     The data sets for the exercises in Rnotes (*note What documentation
991
     The data sets for the exercises in "An Introduction to R" (*note What
979
     exists for R?::).
992
     documentation exists for R?::).
980
 
993
 
981
*SASmixed*
994
*SASmixed*
982
     Data sets and sample lme analyses corresponding to the examples in "SAS
995
     Data sets and sample linear mixed effects analyses corresponding to the
983
     System for Mixed Models" by Littel, Milliken, Stroup and Wolfinger,
996
     examples in "SAS System for Mixed Models" by Littel, Milliken, Stroup
984
     1996, SAS Institute.
997
     and Wolfinger, 1996, SAS Institute.
985
 
998
 
986
*acepack*
999
*acepack*
987
     ace (Alternating Conditional Expectations) and avas (Additivity and
1000
     ace (Alternating Conditional Expectations) and avas (Additivity and
988
     VAriance Stabilization for regression) for selecting regression
1001
     VAriance Stabilization for regression) for selecting regression
989
     transformations.
1002
     transformations.
Line 1151... Line 1164...
1151
*stataread*
1164
*stataread*
1152
     Read and write Stata v6 `.dta' files.
1165
     Read and write Stata v6 `.dta' files.
1153
 
1166
 
1154
*survival5*
1167
*survival5*
1155
     Functions for survival analysis, version 5 (suggests *date*), the main
1168
     Functions for survival analysis, version 5 (suggests *date*), the main
1156
     new feature being penalised (partial) likelihood.
1169
     new feature being penalized (partial) likelihood.
1157
 
1170
 
1158
*tree*
1171
*tree*
1159
     Classification and regression trees.
1172
     Classification and regression trees.
1160
 
1173
 
1161
*tripack*
1174
*tripack*
Line 1257... Line 1270...
1257
     $ R INSTALL -l LIB /path/to/PKG_VERSION.tar.gz
1270
     $ R INSTALL -l LIB /path/to/PKG_VERSION.tar.gz
1258
 
1271
 
1259
where LIB gives the path to the library tree to install to.
1272
where LIB gives the path to the library tree to install to.
1260
 
1273
 
1261
   Even more conveniently, you can install and automatically update
1274
   Even more conveniently, you can install and automatically update
1262
packages from within R if you have access to CRAN.  See the documentation
1275
packages from within R if you have access to CRAN.  See the help page for
1263
for `CRAN.packages()' for more information.
1276
`CRAN.packages()' for more information.
1264
 
1277
 
1265
   You can use several library trees of add-on packages.  The easiest way
1278
   You can use several library trees of add-on packages.  The easiest way
1266
to tell R to use these is via the environment variable `R_LIBS' which
1279
to tell R to use these is via the environment variable `R_LIBS' which
1267
should be a colon-separated list of directories at which R library trees
1280
should be a colon-separated list of directories at which R library trees
1268
are rooted.  You do not have to specify the default tree in `R_LIBS'.
1281
are rooted.  You do not have to specify the default tree in `R_LIBS'.
1269
E.g., to use a private tree in `$HOME/lib/R' and a public site-wide tree in
1282
E.g., to use a private tree in `$HOME/lib/R' and a public site-wide tree in
1270
`/usr/local/lib/R/site', put
1283
`/usr/local/lib/R-contrib', put
1271
 
1284
 
1272
     R_LIBS="$HOME/lib/R:/usr/local/lib/R/site"; export R_LIBS
1285
     R_LIBS="$HOME/lib/R:/usr/local/lib/R-contrib"; export R_LIBS
1273
 
1286
 
1274
into your (Bourne) shell profile or your `~/.Renviron' file.
1287
into your (Bourne) shell profile or your `~/.Renviron' file.
1275
 
1288
 
1276
5.3 How can add-on packages be used?
1289
5.3 How can add-on packages be used?
1277
====================================
1290
====================================
Line 1346... Line 1359...
1346
`src' (some of which can be missing).  Optionally the package can also
1359
`src' (some of which can be missing).  Optionally the package can also
1347
contain script files `configure' and `cleanup' which are executed before
1360
contain script files `configure' and `cleanup' which are executed before
1348
and after installation.
1361
and after installation.
1349
 
1362
 
1350
   See section "Creating R packages" in `Writing R Extensions', for details.
1363
   See section "Creating R packages" in `Writing R Extensions', for details.
-
 
1364
This manual is included in the R distribution, *note What documentation
1351
This gives information on package structure, the configure and cleanup
1365
exists for R?::, and gives information on package structure, the configure
1352
mechanisms, and on automated package checking and building.
1366
and cleanup mechanisms, and on automated package checking and building.
1353
 
1367
 
1354
   The web page `http://www.biostat.washington.edu/~thomas/Rlib.html'
1368
   The web page `http://www.biostat.washington.edu/~thomas/Rlib.html'
1355
maintained by Thomas Lumley provides information on porting S packages to R.
1369
maintained by Thomas Lumley provides information on porting S packages to R.
1356
 
1370
 
1357
   *Note What is CRAN?::, for information on uploading a package to CRAN.
1371
   *Note What is CRAN?::, for information on uploading a package to CRAN.
Line 1367... Line 1381...
1367
   One place where functionality is still missing is the modeling software
1381
   One place where functionality is still missing is the modeling software
1368
as described in "Statistical Models in S" (see *Note What is S?::);
1382
as described in "Statistical Models in S" (see *Note What is S?::);
1369
Generalized Additive Models (*gam*) and some of the nonlinear modeling code
1383
Generalized Additive Models (*gam*) and some of the nonlinear modeling code
1370
are not there yet.
1384
are not there yet.
1371
 
1385
 
1372
   The R Developer Page (http://developer.r-project.org) acts as an
1386
   The R Developer Page (http://developer.r-project.org/) acts as an
1373
intermediate repository for more or less finalized ideas and plans for the
1387
intermediate repository for more or less finalized ideas and plans for the
1374
R statistical system.  It contains (pointers to) TODO lists, RFCs, various
1388
R statistical system.  It contains (pointers to) TODO lists, RFCs, various
1375
other writeups, ideas lists, and CVS miscellania.
1389
other writeups, ideas lists, and CVS miscellania.
1376
 
1390
 
1377
   Many (more) of the packages available at the Statlib S Repository might
1391
   Many (more) of the packages available at the Statlib S Repository might
Line 1384... Line 1398...
1384
*************
1398
*************
1385
 
1399
 
1386
6.1 Is there Emacs support for R?
1400
6.1 Is there Emacs support for R?
1387
=================================
1401
=================================
1388
 
1402
 
1389
   There is an Emacs package which provides a standard interface between
1403
   There is an Emacs package called ESS ("Emacs Speaks Statistics") which
1390
statistical programs and statistical processes called ESS ("Emacs Speaks
1404
provides a standard interface between statistical programs and statistical
1391
Statistics").  It is intended to provide assistance for interactive
1405
processes.  It is intended to provide assistance for interactive
1392
statistical programming and data analysis.  Languages supported include: S
1406
statistical programming and data analysis.  Languages supported include: S
1393
dialects (S 3/4, S-PLUS 3.x/4.x/5.x, and R), LispStat dialects (XLispStat,
1407
dialects (S 3/4, S-PLUS 3.x/4.x/5.x, and R), LispStat dialects (XLispStat,
1394
ViSta), SAS, Stata, SPSS dialects (SPSS, PSPP) and SCA.
1408
ViSta), SAS, Stata, SPSS dialects (SPSS, PSPP) and SCA.
1395
 
1409
 
1396
   ESS grew out of the desire for bug fixes and extensions to S-mode 4.8
1410
   ESS grew out of the need for bug fixes and extensions to S-mode 4.8
1397
(which was a GNU Emacs interface to S/S-PLUS version 3 only).  The current
1411
(which was a GNU Emacs interface to S/S-PLUS version 3 only).  The current
1398
set of developers desired support for XEmacs, R, S4, and MS Windows.  In
1412
set of developers desired support for XEmacs, R, S4, and MS Windows.  In
1399
addition, with new modes being developed for R, Stata, and SAS, it was felt
1413
addition, with new modes being developed for R, Stata, and SAS, it was felt
1400
a unifying interface and framework for the user interface, would benefit
1414
that a unifying interface and framework for the user interface would
1401
both the user and the developer, by helping both groups conform to standard
1415
benefit both the user and the developer, by helping both groups conform to
1402
Emacs usage.  The end result is an increase in efficiency for statistical
1416
standard Emacs usage.  The end result is an increase in efficiency for
1403
programming and data analysis, over the usual tools.
1417
statistical programming and data analysis, over the usual tools.
1404
 
1418
 
1405
   R support contains code for editing R source code (syntactic indentation
1419
   R support contains code for editing R source code (syntactic indentation
1406
and highlighting of source code, partial evaluations of code, loading and
1420
and highlighting of source code, partial evaluations of code, loading and
1407
error-checking of code, and source code revision maintenance) and
1421
error-checking of code, and source code revision maintenance) and
1408
documentation (syntactic indentation and highlighting of source code,
1422
documentation (syntactic indentation and highlighting of source code,
Line 1458... Line 1472...
1458
the Emacs GUD (Grand Unified Debugger) library with the recommended
1472
the Emacs GUD (Grand Unified Debugger) library with the recommended
1459
debugger GDB, type `M-x gdb' and give the path to the R _binary_, typically
1473
debugger GDB, type `M-x gdb' and give the path to the R _binary_, typically
1460
`R.X11', as argument.  At the gdb prompt, set `R_HOME' and other
1474
`R.X11', as argument.  At the gdb prompt, set `R_HOME' and other
1461
environment variables as needed (using e.g.  `set env R_HOME /path/to/R/',
1475
environment variables as needed (using e.g.  `set env R_HOME /path/to/R/',
1462
but see also below), and start the binary with the desired arguments (e.g.,
1476
but see also below), and start the binary with the desired arguments (e.g.,
1463
`run --vsize 12M').
1477
`run --vsize=12M').
1464
 
1478
 
1465
   If you have ESS, you can do `C-u M-x R<RET>-d gdb' to start an inferior
1479
   If you have ESS, you can do `C-u M-x R <RET> - d <SPC> g d b <RET>' to
1466
R process with arguments `-d gdb'.
1480
start an inferior R process with arguments `-d gdb'.
1467
 
1481
 
1468
   A third option is to start an inferior R process via ESS (`M-x R') and
1482
   A third option is to start an inferior R process via ESS (`M-x R') and
1469
then start GUD (`M-x gdb') giving `$R_HOME/bin/R.X11' as the program to
1483
then start GUD (`M-x gdb') giving the R binary (using its full path name)
1470
debug.  Use the program `ps' to find the process number of the currently
1484
as the program to debug.  Use the program `ps' to find the process number
1471
running R process then use the `attach' command in gdb to attach it to that
1485
of the currently running R process then use the `attach' command in gdb to
1472
process.  One advantage of this method is that you have separate `*R*' and
1486
attach it to that process.  One advantage of this method is that you have
1473
`*gud-gdb*' windows.  Within the `*R*' window you have all the ESS
1487
separate `*R*' and `*gud-gdb*' windows.  Within the `*R*' window you have
1474
facilities, such as object-name completion, that we know and love.
1488
all the ESS facilities, such as object-name completion, that we know and
-
 
1489
love.
1475
 
1490
 
1476
   When using GUD mode for debugging from within Emacs, you may find it
1491
   When using GUD mode for debugging from within Emacs, you may find it
1477
most convenient to use the directory with your code in it as the current
1492
most convenient to use the directory with your code in it as the current
1478
working directory and then make a symbolic link from that directory to the
1493
working directory and then make a symbolic link from that directory to the
1479
R binary.  That way `.gdbinit' can stay in the directory with the code and
1494
R binary.  That way `.gdbinit' can stay in the directory with the code and
Line 1507... Line 1522...
1507
"cons cells" (Lisp programmers will know what they are, others may think of
1522
"cons cells" (Lisp programmers will know what they are, others may think of
1508
them as the building blocks of the language itself, parse trees, etc.), and
1523
them as the building blocks of the language itself, parse trees, etc.), and
1509
the second are thrown on a "heap".  The `--nsize' option can be used to
1524
the second are thrown on a "heap".  The `--nsize' option can be used to
1510
specify the number of cons cells which R is to use (the default is 250000),
1525
specify the number of cons cells which R is to use (the default is 250000),
1511
and the `--vsize' option to specify the size of the vector heap in bytes
1526
and the `--vsize' option to specify the size of the vector heap in bytes
1512
(the default is 6 MB).  Boths options must either be integers or integers
1527
(the default is 6 MB).  Both options must either be integers or integers
1513
ending with `M', `K', or `k' meaning `Mega' (2^20), (computer) `Kilo'
1528
ending with `M', `K', or `k' meaning `Mega' (2^20), (computer) `Kilo'
1514
(2^10), or regular `kilo' (1000).
1529
(2^10), or regular `kilo' (1000).
1515
 
1530
 
1516
   E.g., to read in a table of 5000 observations on 40 numeric variables,
1531
   E.g., to read in a table of 5000 observations on 40 numeric variables,
1517
`R --vsize=6M' should do (which currently is the default).
1532
`R --vsize=6M' should do (which currently is the default).
Line 1593... Line 1608...
1593
or print the value of the wrong `x'.  The other one will likely return zero
1608
or print the value of the wrong `x'.  The other one will likely return zero
1594
if `x' exists, and an error otherwise.
1609
if `x' exists, and an error otherwise.
1595
 
1610
 
1596
   This is because in both cases, the first argument is evaluated in the
1611
   This is because in both cases, the first argument is evaluated in the
1597
calling environment first.  The result (which should be an object of mode
1612
calling environment first.  The result (which should be an object of mode
1598
`expression' or `call') is then evaluated or differentiated.  What you
1613
`"expression"' or `"call"') is then evaluated or differentiated.  What you
1599
(most likely) really want is obtained by "quoting" the first argument upon
1614
(most likely) really want is obtained by "quoting" the first argument upon
1600
surrounding it with `expression()'.  For example,
1615
surrounding it with `expression()'.  For example,
1601
 
1616
 
1602
     R> D(expression(x^2), "x")
1617
     R> D(expression(x^2), "x")
1603
     2 * x
1618
     2 * x
Line 1613... Line 1628...
1613
or
1628
or
1614
 
1629
 
1615
     g <- function(y) eval(substitute(y), sys.frame(sys.parent(n = 2)))
1630
     g <- function(y) eval(substitute(y), sys.frame(sys.parent(n = 2)))
1616
     g(a * b)
1631
     g(a * b)
1617
 
1632
 
1618
   See the help pages for more examples.
1633
   See the help page for `deriv()' for more examples.
1619
 
1634
 
1620
7.7 Why do my matrices lose dimensions?
1635
7.7 Why do my matrices lose dimensions?
1621
=======================================
1636
=======================================
1622
 
1637
 
1623
   When a matrix with a single row or column is created by a subscripting
1638
   When a matrix with a single row or column is created by a subscripting
Line 1626... Line 1641...
1626
by subscripting it will be coerced into a 2 x 3 x 4 array, losing the
1641
by subscripting it will be coerced into a 2 x 3 x 4 array, losing the
1627
unnecessary dimension.  After much discussion this has been determined to
1642
unnecessary dimension.  After much discussion this has been determined to
1628
be a _feature_.
1643
be a _feature_.
1629
 
1644
 
1630
   To prevent this happening, add the option `drop = FALSE' to the
1645
   To prevent this happening, add the option `drop = FALSE' to the
1631
subscripting. For example,
1646
subscripting.  For example,
1632
 
1647
 
1633
     rowmatrix <- mat[2, , drop = FALSE]  # creates a row matrix
1648
     rowmatrix <- mat[2, , drop = FALSE]  # creates a row matrix
1634
     colmatrix <- mat[, 2, drop = FALSE]  # creates a column matrix
1649
     colmatrix <- mat[, 2, drop = FALSE]  # creates a column matrix
1635
     a <- b[1, 1, 1, drop = FALSE]        # creates a 1 x 1 x 1 array
1650
     a <- b[1, 1, 1, drop = FALSE]        # creates a 1 x 1 x 1 array
1636
 
1651
 
Line 1722... Line 1737...
1722
========================
1737
========================
1723
 
1738
 
1724
   We expect R to be Y2K compliant when compiled and run on a Y2K compliant
1739
   We expect R to be Y2K compliant when compiled and run on a Y2K compliant
1725
system.  In particular R does not internally represent or manipulate dates
1740
system.  In particular R does not internally represent or manipulate dates
1726
as two-digit quantities.  However, no guarantee of Y2K compliance is
1741
as two-digit quantities.  However, no guarantee of Y2K compliance is
1727
provided for R.  R is free software and comes with _no warranty whatsover_.
1742
provided for R.  R is free software and comes with _no warranty whatsoever_.
1728
 
1743
 
1729
   R, like any other programming language, can be used to write programs
1744
   R, like any other programming language, can be used to write programs
1730
and manipulate data in ways that are not Y2K compliant.
1745
and manipulate data in ways that are not Y2K compliant.
1731
 
1746
 
-
 
1747
7.13 How do I convert factors to numeric?
-
 
1748
=========================================
-
 
1749
 
-
 
1750
   It may happen that when reading numeric data into R (usually, when
-
 
1751
reading in a file), they come in as factors.  If `f' is such a factor
-
 
1752
object, you can use
-
 
1753
 
-
 
1754
     as.numeric(as.character(f))
-
 
1755
 
-
 
1756
to get the numbers back.  More efficient, but harder to remember, is
-
 
1757
 
-
 
1758
     as.numeric(levels(f))[as.integer(f)]
-
 
1759
 
-
 
1760
   In any case, do not call `as.numeric' or their likes directly.
-
 
1761
 
1732
8 R Programming
1762
8 R Programming
1733
***************
1763
***************
1734
 
1764
 
1735
8.1 How should I write summary methods?
1765
8.1 How should I write summary methods?
1736
=======================================
1766
=======================================
1737
 
1767
 
1738
   Suppose you want to provide a summary method for class `foo'.  Then
1768
   Suppose you want to provide a summary method for class `foo'.  Then
1739
`summary.foo()' should not print anything, but return an object of class
1769
`summary.foo()' should not print anything, but return an object of class
1740
`summary.foo', _and_ you should write a method `print.summary.foo()' which
1770
`"summary.foo"', _and_ you should write a method `print.summary.foo()'
1741
nicely prints the summary information and invisibly returns its object.
1771
which nicely prints the summary information and invisibly returns its
1742
This approach is preferred over having `summary.foo()' print summary
1772
object.  This approach is preferred over having `summary.foo()' print
1743
information and return something useful, as sometimes you need to grab
1773
summary information and return something useful, as sometimes you need to
1744
something computed by `summary()' inside a function or similar.  In such
1774
grab something computed by `summary()' inside a function or similar.  In
1745
cases you don't want anything printed.
1775
such cases you don't want anything printed.
1746
 
1776
 
1747
8.2 How can I debug dynamically loaded code?
1777
8.2 How can I debug dynamically loaded code?
1748
============================================
1778
============================================
1749
 
1779
 
-
 
1780
   Roughly speaking, you need to start R inside the debugger, load the
-
 
1781
code, send an interrupt, and then set the required breakpoints.
-
 
1782
 
1750
   See section "Finding entry points in dynamically loaded code" in
1783
   See section "Finding entry points in dynamically loaded code" in
-
 
1784
`Writing R Extensions'.  This manual is included in the R distribution,
1751
`Writing R Extensions'.
1785
*note What documentation exists for R?::.
1752
 
1786
 
1753
8.3 How can I inspect R objects when debugging?
1787
8.3 How can I inspect R objects when debugging?
1754
===============================================
1788
===============================================
1755
 
1789
 
-
 
1790
   The most convenient way is to call `R_PV' from the symbolic debugger.
-
 
1791
 
1756
   See section "Inspecting R objects when debugging" in `Writing R
1792
   See section "Inspecting R objects when debugging" in `Writing R
1757
Extensions'.
1793
Extensions'.
1758
 
1794
 
1759
9 R Bugs
1795
9 R Bugs
1760
********
1796
********
Line 1774... Line 1810...
1774
time.  If the input was such that you _know_ it should have been processed
1810
time.  If the input was such that you _know_ it should have been processed
1775
quickly, report a bug.  If you don't know whether the command should take a
1811
quickly, report a bug.  If you don't know whether the command should take a
1776
long time, find out by looking in the manual or by asking for assistance.
1812
long time, find out by looking in the manual or by asking for assistance.
1777
 
1813
 
1778
   If a command you are familiar with causes an R error message in a case
1814
   If a command you are familiar with causes an R error message in a case
1779
where its usual definition ought to be reasonable, it is probably a bug. If
1815
where its usual definition ought to be reasonable, it is probably a bug.
1780
a command does the wrong thing, that is a bug.  But be sure you know for
1816
If a command does the wrong thing, that is a bug.  But be sure you know for
1781
certain what it ought to have done.  If you aren't familiar with the
1817
certain what it ought to have done.  If you aren't familiar with the
1782
command, or don't know for certain how the command is supposed to work,
1818
command, or don't know for certain how the command is supposed to work,
1783
then it might actually be working right.  Rather than jumping to
1819
then it might actually be working right.  Rather than jumping to
1784
conclusions, show the problem to someone who knows for certain.
1820
conclusions, show the problem to someone who knows for certain.
1785
 
1821
 
Line 1821... Line 1857...
1821
   For example, suppose that on a data set which you know to be quite large
1857
   For example, suppose that on a data set which you know to be quite large
1822
the command
1858
the command
1823
 
1859
 
1824
     R> data.frame(x, y, z, monday, tuesday)
1860
     R> data.frame(x, y, z, monday, tuesday)
1825
 
1861
 
1826
never returns. Do not report that `data.frame()' fails for large data sets.
1862
never returns.  Do not report that `data.frame()' fails for large data
1827
Perhaps it fails when a variable name is a day of the week.  If this is so
1863
sets.  Perhaps it fails when a variable name is a day of the week.  If this
1828
then when others got your report they would try out the `data.frame()'
1864
is so then when others got your report they would try out the
1829
command on a large data set, probably with no day of the week variable
1865
`data.frame()' command on a large data set, probably with no day of the
1830
name, and not see any problem.  There is no way in the world that others
1866
week variable name, and not see any problem.  There is no way in the world
1831
could guess that they should try a day of the week variable name.
1867
that others could guess that they should try a day of the week variable
-
 
1868
name.
1832
 
1869
 
1833
   Or perhaps the command fails because the last command you used was a
1870
   Or perhaps the command fails because the last command you used was a
1834
method for `"["()' that had a bug causing R's internal data structures to
1871
method for `"["()' that had a bug causing R's internal data structures to
1835
be corrupted and making the `data.frame()' command fail from then on.  This
1872
be corrupted and making the `data.frame()' command fail from then on.  This
1836
is why others need to know what other commands you have typed (or read from
1873
is why others need to know what other commands you have typed (or read from
1837
your startup file).
1874
your startup file).
1838
 
1875
 
1839
   It is very useful to try and find simple examples that produce
1876
   It is very useful to try and find simple examples that produce
1840
apparently the same bug, and somewhat useful to find simple examples that
1877
apparently the same bug, and somewhat useful to find simple examples that
1841
might be expected to produce the bug but actually do not.  If you want to
1878
might be expected to produce the bug but actually do not.  If you want to
1842
debug the problem and find exactly what caused it, that is wonderful. You
1879
debug the problem and find exactly what caused it, that is wonderful.  You
1843
should still report the facts as well as any explanations or solutions.
1880
should still report the facts as well as any explanations or solutions.
1844
Please include an example that reproduces the problem, preferably the
1881
Please include an example that reproduces the problem, preferably the
1845
simplest one you have found.
1882
simplest one you have found.
1846
 
1883
 
1847
   Invoking R with the `--vanilla' option may help in isolating a bug. This
1884
   Invoking R with the `--vanilla' option may help in isolating a bug.
1848
ensures that the site profile and saved data files are not read.
1885
This ensures that the site profile and saved data files are not read.
1849
 
1886
 
1850
   On Unix systems a bug report can be generated using the function
1887
   On Unix systems a bug report can be generated using the function
1851
`bug.report()'. This automatically includes the version information and
1888
`bug.report()'.  This automatically includes the version information and
1852
sends the bug to the correct address.  Alternatively the bug report can be
1889
sends the bug to the correct address.  Alternatively the bug report can be
1853
emailed to <r-bugs@lists.r-project.org> or submitted to the Web page at
1890
emailed to <r-bugs@lists.r-project.org> or submitted to the Web page at
1854
`http://bugs.r-project.org'.
1891
`http://bugs.r-project.org/'.
1855
 
1892
 
1856
   Bug reports on contributed packages should perhaps be sent to the
1893
   Bug reports on contributed packages should perhaps be sent to the
1857
package maintainer rather than to r-bugs.
1894
package maintainer rather than to r-bugs.
1858
 
1895
 
1859
10 Acknowledgments
1896
10 Acknowledgments