-
Notifications
You must be signed in to change notification settings - Fork 315
/
R-admin.html
1283 lines (990 loc) · 56 KB
/
R-admin.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html lang="en">
<head>
<title>R Installation and Administration</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="R Installation and Administration">
<meta name="generator" content="makeinfo 4.6">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
--></style>
</head>
<body>
<h1 class="settitle">R Installation and Administration</h1>
<a name="Top"></a>
<h2 class="unnumbered">R Installation and Administration</h2>
<p>This is a guide to installation and administration for R.
<p>The current version of this document is 1.9.0 (2003-10-11).
ISBN 3-901167-52-8
<a name="Obtaining%20R"></a>
<h2 class="chapter">1 Obtaining R</h2>
<p>Sources, binaries and documentation for R can be obtained via
<small>CRAN</small>, the "Comprehensive R Archive Network". See the file
<code>RESOURCES</code> in the R distribution for information on
<small>CRAN</small>.
<a name="Getting%20and%20unpacking%20the%20sources"></a>
<h3 class="section">1.1 Getting and unpacking the sources</h3>
<p>The simplest way is to download the most recent
<code>R-</code><var>x</var><code>.</code><var>y</var><code>.</code><var>z</var><code>.tgz</code> file, and unpack it with
<pre class="smallexample"> tar xvfz R-<var>x</var>.<var>y</var>.<var>z</var>.tgz
</pre>
<p>on systems that have GNU <code>tar</code> installed. On other systems you
need at least to have the <code>gzip</code> program installed. Then you
can use
<pre class="smallexample"> gzip -dc R-<var>x</var>.<var>y</var>.<var>z</var>.tgz | tar xvf -
</pre>
<p>If you need to transport the sources on floppy disks, you can download
the <code>R-</code><var>x</var><code>.</code><var>y</var><code>.</code><var>z</var><code>.tgz-split.*</code> files and paste them
together at the destination with (Unix)
<pre class="smallexample"> cat R-<var>x</var>.<var>y</var>.<var>z</var>-split.* > R-<var>x</var>.<var>y</var>.<var>z</var>.tgz
</pre>
<p>and proceed as above. If you want the build to be usable by a group of
users, set <code>umask</code> before unpacking so that the files will be
readable by the target group (e.g., <code>umask 022</code> to be usable by all
users).
<a name="Using%20rsync"></a>
<h3 class="section">1.2 Using rsync</h3>
<p>Sources are also available via anonymous rsync. Use
<pre class="smallexample"> rsync -rC rsync.r-project.org::<var>module</var> R
</pre>
<p>to create a copy of the source tree specified by <var>module</var> in the
subdirectory <code>R</code> of the current directory, where <var>module</var>
specifies one of the four existing flavors of the R sources, and can be
one of <code>r-release</code> (current released version), <code>r-patched</code>
(patched released version), and <code>r-devel</code> (development version).
(These flavors are described in the R FAQ,
<a href="http://www.ci.tuwien.ac.at/~hornik/R/">http://www.ci.tuwien.ac.at/~hornik/R/</a>.) The rsync trees are
created directly from the master CVS archive and are updated hourly.
The <code>-C</code> option in the <code>rsync</code> command is to cause it to
skip the CVS directories. Further information on <code>rsync</code> is
available at <a href="http://rsync.samba.org/rsync/">http://rsync.samba.org/rsync/</a>.
<a name="Installing%20R%20under%20Unix"></a>
<h2 class="chapter">2 Installing R under Unix</h2>
<p>R will configure and build under a number of common Unix platforms
including i386-freebsd, <var>cpu</var>-linux-gnu for the i386, alpha, arm,
hppa, ia64, m68k, powerpc, and sparc CPUs (see e.g.
<a href="http://buildd.debian.org/build.php?&pkg=r-base">http://buildd.debian.org/build.php?&pkg=r-base</a>),
i386-sun-solaris, powerpc-apple-darwin, mips-sgi-irix, alpha-dec-osf4,
rs6000-ibm-aix, hppa-hp-hpux, and sparc-sun-solaris.
<p>In addition, binary distributions are available for most common Linux
distributions, and for MacOS X (Darwin) with X11. See the <small>FAQ</small>
for current details. These are installed in platform-specific ways. So
for the rest of this chapter we consider only building from the sources.
<a name="Simple%20compilation"></a>
<h3 class="section">2.1 Simple compilation</h3>
<p>First review the essential and useful tools and libraries in
<a href="#Essential%20and%20useful%20other%20programs">Essential and useful other programs</a>, and install those you want or
need.
<p>Choose a place to install the R tree (R is not just a binary, but
has additional data sets, help files, font metrics etc). Let us call
this place <var>R_HOME</var>. Untar the source code. This should create
directories <code>src</code>, <code>doc</code>, and several more. Issue the
following commands:
<pre class="smallexample"> ./configure
make
</pre>
<p>(See <a href="#Using%20make">Using make</a> if your make is not called <code>make</code>.)
<p>Then check the built system works correctly, by
<pre class="smallexample"> make check
</pre>
<p>Failures are not necessarily problems as they might be caused by missing
functionality, but you should look carefully at any reported
discrepancies. To re-run the tests you would need
<pre class="smallexample"> make check FORCE=FORCE
</pre>
<p>More comprehensive testing can be done by
<pre class="smallexample"> make check-devel
</pre>
<p>or
<pre class="smallexample"> make check-all
</pre>
<p>see <code>tests/README</code>.
<p>If these commands execute successfully, the R binary will be copied
to the <code></code><var>R_HOME</var><code>/bin</code> directory. In addition, a shell-script
front-end called <code>R</code> will be created and copied to the same
directory. You can copy this script to a place where users can invoke
it, for example to <code>/usr/local/bin/R</code>. You could also copy the man
page <code>R.1</code> to a place where your <code>man</code> reader finds it,
such as <code>/usr/local/man/man1</code>. If you want to install the complete
R tree to, e.g., <code>/usr/local/lib/R</code>, see <a href="#Installation">Installation</a>.
Note: you do not <em>need</em> to install R: you can run it from where
it was built.
<p>You do not necessarily have to build R in the top-level source
directory (say, <code></code><var>TOP_SRCDIR</var><code></code>). To build in
<code></code><var>BUILDDIR</var><code></code>, run
<pre class="smallexample"> cd <var>BUILDDIR</var>
<var>TOP_SRCDIR</var>/configure
make
</pre>
<p>and so on, as described further below. This has the advantage of always
keeping your source tree "clean". (You may need GNU <code>make</code> to
allow this.)
<p>Make will also build plain text help pages as well as <small>HTML</small> and
LaTeX versions of the R object documentation (the three kinds can
also be generated separately using <code>make help</code>, <code>make html</code>
and <code>make latex</code>). Note that you need Perl version 5: if this is
not available on your system, you can obtain PDF versions of the
documentation files via <small>CRAN</small>.
<p>Now <code>rehash</code> if necessary, type <kbd>R</kbd>, and read the R manuals
and the R <small>FAQ</small> (files <code>FAQ</code> or
<code>doc/html/faq.html</code>, or
<a href="http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html">http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html</a> which always has
the latest version).
<a name="Making%20the%20manuals"></a>
<h3 class="section">2.2 Making the manuals</h3>
<p>There is a set of manuals that can be built from the sources,
<dl>
<dt><code>refman</code>
<dd>Printed versions of all the help pages.
<br><dt><code>R-FAQ</code>
<dd>R <small>FAQ</small> (which is already built for you).
<br><dt><code>R-intro</code>
<dd>"An Introduction to R".
<br><dt><code>R-data</code>
<dd>"R Data Import/Export".
<br><dt><code>R-admin</code>
<dd>"R Installation and Administration", this manual.
<br><dt><code>R-exts</code>
<dd>"Writing R Extensions".
<br><dt><code>R-lang</code>
<dd>"The R Language Definition".
</dl>
<p>To make these, use
<pre class="smallexample"> make dvi to create DVI versions
make pdf to create PDF versions
make info to create info files (not <code>refman</code>).
</pre>
<p>You will not be able to build the info files unless you have
<code>makeinfo</code> version 4 or later installed (and some Linux
distributions have 3.12).
<p>The DVI versions can be previewed and printed using standard programs
such as <code>xdvi</code> and <code>dvips</code>. The PDF versions can be
viewed using Acrobat Reader or (recent versions of) ghostscript: they
have hyperlinks that can be followed in Acrobat Reader. The info files
are suitable for reading online with Emacs or the standalone GNU Info.
<a name="Installation"></a>
<h3 class="section">2.3 Installation</h3>
<p>After
<pre class="smallexample"> ./configure
make
make check
</pre>
<p>have been completed successfully, you can install the complete R tree
to your system by typing
<pre class="smallexample"> make install
</pre>
<p>This will install to the following directories:
<dl>
<dt><code></code><var>prefix</var><code>/bin</code>
<dd>the front-end shell script
<br><dt><code></code><var>prefix</var><code>/man/man1</code>
<dd>the man page
<br><dt><code></code><var>prefix</var><code>/lib/R</code>
<dd>all the rest (libraries, on-line help system, <small class="dots">...</small>)
</dl>
<p>where <var>prefix</var> is determined during configuration (typically
<code>/usr/local</code>) and can be set by running <code>configure</code> with
the option <code>--prefix</code>, as in
<pre class="smallexample"> ./configure --prefix=/where/you/want/R/to/go
</pre>
<p>This causes <code>make install</code> to install the R executable to
<code>/where/you/want/R/to/go/bin</code>, and so on. The prefix of the
installation directories can be seen in the status message that is
displayed at the end of <code>configure</code>. You can install into
another directory by using
<pre class="smallexample"> make prefix=/path/to/here install
</pre>
<p>To install DVI, info and PDF versions of the manuals, use one or more of
<pre class="smallexample"> make install-dvi
make install-info
make install-pdf
</pre>
<p>To ensure that the installed tree is usable by the right group of users,
set <code>umask</code> appropriately (perhaps to <code>022</code>) before unpacking
the sources and throughout the build process.
<a name="Installing%20R%20under%20Windows"></a>
<h2 class="chapter">3 Installing R under Windows</h2>
<p>The <code>bin/windows</code> directory of a <small>CRAN</small> site contains
binaries for a base distribution and a large number of add-on packages
from <small>CRAN</small> to run on Windows 95, 98, NT4, 2000, ME and XP (at
least) on Intel and clones (but not on other platforms).
<p>You do need one of those Windows versions: Windows 3.11+win32s will not
work.
<p>Your file system must allow long file names (as is likely except
perhaps for some network-mounted systems).
<p>The simplest way is to use <code>rw1090dev.exe</code> or
<code>miniR.exe</code>. Just double-click on the icon and follow the
instructions. If you installed R this way you can uninstall it from the
Control Panel.
<p>See the <a href="http://www.stats.ox.ac.uk/pub/R/rw-FAQ.html">R Windows <small>FAQ</small></a> for more details.
<a name="Building%20from%20source"></a>
<h3 class="section">3.1 Building from source</h3>
<p>If you want to build this port from the sources, see the file
<code>src/gnuwin32/INSTALL</code> in the source distribution. You will need
to collect, install and test an extensive set of tools: see
<a href="http://www.stats.ox.ac.uk/pub/Rtools/">http://www.stats.ox.ac.uk/pub/Rtools/</a> for the current locations.
<p>You may need to compile under a case-honouring file system: we found
that a <code>samba</code>-mounted file system (which maps all file names to
lower case) did not work. Open a commands window at a directory <em>whose
path does not contain spaces</em>, and run something like
<pre class="smallexample"> tar zxvf R-1.9.0.tgz
cd R-1.9.0\src\gnuwin32
make
</pre>
<p>sit back and wait (for about 5 minutes on 1GHz PIII with a fast local
disc).
<p>For further details, including how to make the documentation and how to
cross-compile, see <code>src/gnuwin32/INSTALL</code>.
<a name="Add-on%20packages"></a>
<h2 class="chapter">4 Add-on packages</h2>
<p>This chapter applies to Unix-like and Windows versions of R.
<p>It is helpful to use the correct terminology. A <em>package</em> is
loaded from a <em>library</em> by the function <code>library()</code>. Thus a
library is a directory containing installed packages; the main library
is <code></code><var>R_HOME</var><code>/library</code>, but others can be used, for example by
setting the environment variable <code>R_LIBS</code> or using the R function
<code>.libPaths()</code>.
<a name="Installing%20packages"></a>
<h3 class="section">4.1 Installing packages</h3>
<p>Packages may be distributed in source form or compiled binary form.
Installing source packages requires that compilers and tools
(including Perl 5.004 or later) be installed. Binary packages
are platform specific and generally need
no special tools to install, but see the documentation for
your platform for details.
<p>Note that you need to specify implicitly or explicitly the library to
which the package is to be installed. This is only an issue if you have
more than one library, of course.
<p>To install packages from source on Unix use
<pre class="smallexample"> R CMD INSTALL -l /path/to/library <var>pkg1</var> <var>pkg2</var> ...
</pre>
<p>The part <code>-l /path/to/library</code> can be omitted, in which case the
first library in <code>R_LIBS</code> is used if set, otherwise the main
library <code></code><var>R_HOME</var><code>/library</code> is used. (<code>R_LIBS</code> is looked
for in the environment: <code>.Renviron</code> is not read by <code>R CMD</code>.)
<p>The Windows equivalent is<a rel="footnote" href="#fn-1"><sup>1</sup></a>
<pre class="smallexample"> Rcmd INSTALL -l /path/to/library <var>pkg1</var> <var>pkg2</var> ...
</pre>
<p>Alternatively, packages can be downloaded and installed from within
R. First set the option <code>CRAN</code> to your nearest <small>CRAN</small>
mirror, for example
<pre class="smallexample"> > options(CRAN = "http://cran.us.r-project.org/")
</pre>
<p>Then download and install package <strong>foo</strong> by
<pre class="smallexample"> > install.packages("foo")
</pre>
<p>Unless the library is specified (argument <code>lib</code>) the first library
in the library search path is used.
<p>What this does is different on Unix and Windows. On Unix it consults
the list of available source packages on <small>CRAN</small>, downloads the
latest version of the <strong>foo</strong> sources, and installs it (via <code>R
CMD INSTALL</code>). On Windows it looks at the list of <em>binary</em>
versions of packages and downloads the latest version (if any).
<p>On Windows <code>install.packages</code> can also install a binary package
from a local <code>zip</code> file by setting argument <code>CRAN</code> to
<code>NULL</code>. <code>RGui.exe</code> has a menu <code>Packages</code> with a GUI
interface to <code>install.packages</code>, <code>update.packages</code> and
<code>library</code>.
<a name="Updating%20packages"></a>
<h3 class="section">4.2 Updating packages</h3>
<p>The command <code>update.packages()</code> is the simplest way to ensure that
all the packages on your system are up to date. Set the <code>CRAN</code>
option as in the previous section. The <code>update.packages()</code>
downloads the list of available packages and their current versions,
compares it with those installed and offers to fetch and install any
that have later versions on <small>CRAN</small>.
<p>An alternative way of keeping packages up-to-date is provided by the
command <code>packageStatus()</code>, which returns an object with information
on all installed packages and packages available at multiple
repositories (CRAN, local archive, <small class="dots">...</small>). The <code>print</code> and
<code>summary</code> methods give an overview of installed and available
packages, the <code>upgrade</code> method offers to fetch and install outdated
packages. This allows R to fetch packages from several repositories and
keep in sync with all of them, instead of only one CRAN mirror, and is
intended to become the default package manager for future versions of R.
<a name="Removing%20packages"></a>
<h3 class="section">4.3 Removing packages</h3>
<p>Packages can be removed in a number of ways. From a command prompt they
can be removed by
<pre class="smallexample"> R CMD REMOVE -l /path/to/library <var>pkg1</var> <var>pkg2</var> ...
</pre>
<p>(Unix) or
<pre class="smallexample"> Rcmd REMOVE -l /path/to/library <var>pkg1</var> <var>pkg2</var> ...
</pre>
<p>(Windows).
<p>From a running R process they can be removed by
<pre class="smallexample"> > remove.packages(c("pkg1", "pkg2"),
lib = file.path("path", "to", "library"))
</pre>
<p>Finally, in most installations one can just remove the package directory
from the library.
<p><strong>Note:</strong> whereas it is currently possible to install package
<em>bundles</em>, one cannot remove these as such--the packages contained
in the bundle have to removed individually.
<a name="Essential%20and%20useful%20other%20programs"></a>
<h2 class="appendix">Appendix A Essential and useful other programs</h2>
<p>This appendix gives details of programs you will need to build R on
Unix-like platforms, or which will be used by R if found by
<code>configure</code>.
<a name="Essential%20programs"></a>
<h3 class="section">A.1 Essential programs</h3>
<p>You need a means of compiling C and FORTRAN 77 (see <a href="#Using%20FORTRAN">Using FORTRAN</a>). Some add-on packages also need a C++ compiler.
<p>You will need Perl version 5.004 or later, available via
<a href="http://www.perl.com/CPAN/">http://www.perl.com/CPAN/</a>, to build any of the on-line
documentation.
<p>You will not be able to build the info files unless you have
<code>makeinfo</code> version 4 or later installed.
<p>The typeset documentation needs <code>tex</code> and <code>latex</code>, or
<code>pdftex</code> and <code>pdflatex</code>.
<a name="Useful%20libraries%20and%20programs"></a>
<h3 class="section">A.2 Useful libraries and programs</h3>
<p>The command-line editing depends on the <code>readline</code> library
available from any GNU mirror: you will need a fairly recent version.
<p>The bitmapped graphics devices <code>jpeg()</code> and <code>png()</code> need the
appropriate headers and libraries installed: <code>jpeg</code> (version 6b
or later) or <code>libpng</code> (version 1.2.3 or later) and <code>zlib</code>
(version 1.1.3 or later) respectively.
<p>The <code>bitmap</code> and <code>dev2bitmap</code> devices make use of ghostscript
(<a href="http://www.cs.wisc.edu/~ghost">http://www.cs.wisc.edu/~ghost</a>).
<p>If you have them installed (including the approrpiate headers),
<code>zlib</code>, <code>libbz2</code> and PCRE will be used: otherwise versions
in the R sources will be compiled in.
<a name="Tcl%2fTk"></a>
<h3 class="subsection">A.2.1 Tcl/Tk</h4>
<p>The <strong>tcltk</strong> package needs Tcl/Tk installed: the sources are
available at <a href="http://www.scriptics.com/">http://www.scriptics.com/</a>. To specify the locations
of the Tcl/Tk files you may need the configuration options
<dl>
<dt><code>--with-tcltk</code>
<dd>use Tcl/Tk, or specify its library directory
<br><dt><code>--with-tcl-config=</code><var>TCL_CONFIG</var><code></code>
<dd>specify location of <code>tclConfig.sh</code>
<br><dt><code>--with-tk-config=</code><var>TK_CONFIG</var><code></code>
<dd>specify location of <code>tkConfig.sh</code>
</dl>
<p>or use the configure variables <code>TCLTK_LIBS</code> and
<code>TCLTK_CPPFLAGS</code> to specify the flags needed for linking against
the Tcl and Tk libraries and for finding the <code>tcl.h</code> and
<code>tk.h</code> headers, respectively.
<p>Versions of Tcl/TK from 8.0 to 8.4.1 have been used successfully.
<a name="Linear%20algebra"></a>
<h3 class="subsection">A.2.2 Linear algebra</h4>
<p>The linear algebra routines in R can make use of enhanced BLAS (Basic
Linear Algebra Subprograms, <a href="http://www.netlib.org/blas/faq.html">http://www.netlib.org/blas/faq.html</a>)
routines. Some are compiler-system-specific (<code>libsunperf</code> on Sun
Sparc<a rel="footnote" href="#fn-2"><sup>2</sup></a>, <code>libessl</code> on IBM, <code>vecLib</code> on MacOS
X) but ATLAS (<a href="http://math-atlas.sourceforge.net/">http://math-atlas.sourceforge.net/</a>) is a "tuned"
BLAS that runs on a wide range of Unix-alike platforms. If no more
specific library is found, a <code>libblas</code> library in the library path
will be used. You can specify a specific BLAS library by the
configuration option <code>--with-blas</code> and not to use an external
BLAS library by <code>--without-blas</code>.
<p>For systems with multiple processors it is in principle possible to use
a multi-threaded version of ATLAS. Prior to R 1.8.0 this was not
supported since <code>SIGINT</code> signals sent to the process and handled by
the wrong thread could result in segfaults. Changes in <code>SIGINT</code>
handling introduced in R 1.8.0 should make it safe to use a
multi-threaded ATLAS. A remaining issue is that R profiling, which
uses the <code>SIGPROF</code> signal, may cause problems. You may want to
disable profiling if you use a multi-threaded version of ATLAS. You can
use a multi-threaded ATLAS by specifying
<pre class="smallexample"> --with-blas="-lptf77blas -lpthread -latlas"
</pre>
<p>Note that the BLAS library will be used for several add-on packages as
well as for R itself. This means that it is better to use a shared
BLAS library, as most of a static library will be compiled into the R
executable and each BLAS-using package. In any case, the BLAS library
must be usable with dynamically-loadable code.
<p>You will need double-precision and double-complex versions of the BLAS,
but not single-precision nor complex routines.
<p>As from R 1.7.0, provision is made for using an external LAPACK
library, principally to cope with BLAS libraries which contain a copy of
LAPACK (such as <code>libsunperf</code> on Solaris and <code>vecLib</code> on MacOS
10.2.2). However, the likely performance gains are thought to be small
(and may be negative), and the default is not to search for a suitable
LAPACK library. You can specify a specific LAPACK library or a search
for a generic library by the configuration option
<code>--with-lapack</code>. The default for <code>--with-lapack</code> is to
check the BLAS library and then look for an external library
<code>-llapack</code>. Sites searching for the fastest possible linear
algebra may want to build a LAPACK library using the ATLAS-optimized
subset of LAPACK. To do so specify something like
<pre class="smallexample"> --with-lapack="-L/path/to/libs -llapack -lcblas"
</pre>
<p>since the ATLAS subset of LAPACK depends on <code>libcblas</code>.
<p>If you do use <code>--with-lapack</code>, be aware of potential problems
with bugs in the LAPACK 3.0 sources (or in the posted corrections to those
sources). In particular, bugs in <code>DGEEV</code> and <code>DGESDD</code> have
resulted in error messages such as
<pre class="smallexample"> DGEBRD gave error code -10
</pre>
<p>(from the Debian <code>-llapack</code> which was current in late 2002). Other
potential problems are incomplete versions of the libraries: for example
<code>libsunperf</code> from Sun Forte 6.x was missing the entry point for
<code>DLANGE</code> and <code>vecLib</code> has omitted the BLAS routine
<code>LSAME</code>.
<p>As with all libraries, you need to ensure that they and R were
compiled with compatible compilers and flags. For example, this means
that on Sun Sparc using the native compilers the flag <code>-dalign</code>
is needed so <code>libsunperf</code> can be used.
<p>An ATLAS `tuned' BLAS can also be used on Windows: see
<code>src/gnuwin32/INSTALL</code> for how to enable this when building from
source, and <a href="http://www.stats.ox.ac.uk/pub/R/rw-FAQ.html">R Windows <small>FAQ</small></a> for adding pre-compiled support to binary versions.
<p>Note that under Unix (but not under Windows) if R is compiled
against a non-default BLAS, then all BLAS-using packages must also be.
So if R is re-built after ATLAS is installed, then packages such as
<strong>quantreg</strong> will need to be re-installed.
<a name="Configuration%20on%20Unix"></a>
<h2 class="appendix">Appendix B Configuration on Unix</h2>
<a name="Configuration%20options"></a>
<h3 class="section">B.1 Configuration options</h3>
<p><code>configure</code> has many options: running
<pre class="smallexample"> ./configure --help
</pre>
<p>will give a list. Probably the most important ones not covered
elsewhere are (defaults in brackets)
<dl>
<dt><code>--with-x</code>
<dd>use the X Window System
<br><dt><code>--x-includes=</code><var>DIR</var><code></code>
<dd>X include files are in <var>DIR</var>
<br><dt><code>--x-libraries=</code><var>DIR</var><code></code>
<dd>X library files are in <var>DIR</var>
<br><dt><code>--with-readline</code>
<dd>use readline library (if available) [yes]
<br><dt><code>--enable-R-profiling</code>
<dd>attempt to compile support for <code>Rprof()</code> [yes]
<br><dt><code>--enable-R-shlib</code>
<dd>build R as a shared library [no]
</dl>
<p>You can use <code>--without-foo</code> or <code>--disable-foo</code> for the
negatives.
<p>You will want to use <code>--disable-R-profiling</code> if you are building
a profiled executable of R (e.g. with <code>-pg)</code>.
<p>Flag <code>--enable-R-shlib</code> causes the make process to build R as a
shared library, typically called <code>libR.so</code>, and to take
considerably longer, so you probably only want this if you will be using
an application which embeds R.
<a name="Configuration%20variables"></a>
<h3 class="section">B.2 Configuration variables</h3>
<p>If you need or want to set certain configure variables to something
other than their default, you can do that by either editing the file
<code>config.site</code> (which documents all the variables you might want to
set) or on the command line as
<pre class="smallexample"> ./configure VAR=<var>value</var>
</pre>
<p>These variables are <em>precious</em>, implying that they do not have to
be exported to the environment, are kept in the cache even if not
specified on the command line and checked for consistency between two
configure runs (provided that caching is used), and are kept during
automatic reconfiguration as if having been passed as command line
arguments, even if no cache is used.
<p>See the variable output section of <code>configure --help</code> for a list of
all these variables.
<p>One common variable to change is <code>R_PAPERSIZE</code>, which defaults to
<code>a4</code>, not <code>letter</code>. (Valid values are <code>a4</code>,
<code>letter</code>, <code>legal</code> and <code>executive</code>.)
<p>If you have libraries and header files, e.g., for GNU readline, in
non-system directories, use the variables <code>LDFLAGS</code> (for libraries,
using <code>-L</code> flags to be passed to the linker) and <code>CPPFLAGS</code>
(for header files, using <code>-I</code> flags to be passed to the C/C++
preprocessors), respectively, to specify these locations. These default
to <code>/usr/local/lib</code> and <code>/usr/local/include</code> to catch the most
common cases. If libraries are still not found, then maybe your
compiler/linker does not support re-ordering of <code>-L</code> and
<code>-l</code> flags (this has been reported to be a problem on HP-UX with
the native <code>cc</code>). In this case, use a different compiler (or a
front end shell script which does the re-ordering).
<p>Another precious variable is <code>R_BROWSER</code>, the default browser, which
should take a value of an executable in the user's path or specify
a full path.
<p>If you find you need to alter configure variables, it is worth noting
that some settings may be cached in the file <code>config.cache</code>, and it
is a good idea to remove that file (if it exists) before re-configuring.
Note that caching is turned <em>off</em> by default; use the command line
option <code>--config-cache</code> (or <code>-C</code>) to enable caching.
<a name="Using%20make"></a>
<h3 class="section">B.3 Using make</h3>
<p>To compile R, you will most likely find it easiest to use GNU
<code>make</code>. On Solaris 2.6/7/8 in particular, you need a version of
GNU <code>make</code> different from 3.77; 3.79.1 works fine, as does the Sun
<code>make</code>. The native <code>make</code> is reported to fail on SGI
Irix 6.5 and Alpha/OSF1 (aka Tru64).
<p>To build in a separate directory you need a <code>make</code> that uses the
<code>VPATH</code> variable, for example GNU <code>make</code>, or Sun
<code>make</code> on Solaris 2.7/8 (but not earlier).
<p>If you want to use a <code>make</code> by another name, for example if your
GNU <code>make</code> is called <code>gmake</code>, you need to set the variable
<code>MAKE</code> at configure time, for example
<pre class="smallexample"> ./configure MAKE=gmake
</pre>
<a name="Using%20FORTRAN"></a>
<h3 class="section">B.4 Using FORTRAN</h3>
<p>To compile R, you need a FORTRAN compiler or <code>f2c</code>, the
FORTRAN-to-C converter (<a href="http://www.netlib.org/f2c">http://www.netlib.org/f2c</a>). The default
is to search for <code>g77</code>, <code>f77</code>, <code>xlf</code>,
<code>frt</code>, <code>pgf77</code>, <code>fl32</code>, <code>af77</code>,
<code>fort77</code>, <code>f90</code>, <code>xlf90</code>, <code>pgf90</code>,
<code>epcf90</code>, <code>f95</code>, <code>fort</code>, <code>xlf95</code>,
<code>lf95</code>, <code>g95</code>, and <code>fc</code> (in that
order)<a rel="footnote" href="#fn-3"><sup>3</sup></a>, and
then for <code>f2c</code>, and use whichever is found first; if none is
found, R cannot be compiled. The search mechanism can be changed
using the configure variables <code>F77</code> and <code>F2C</code> which specify
the commands that run the FORTRAN 77 compiler and FORTRAN-to-C
converter, respectively. If <code>F77</code> is given, it is used to compile
FORTRAN; otherwise, if <code>F2C</code> is given, f2c is used even if a
FORTRAN compiler would be be available. If your FORTRAN compiler is in
a non-standard location, you should set the environment variable
<code>PATH</code> accordingly before running <code>configure</code>, or use the
configure variable <code>F77</code> to specify its full path.
<p>If your FORTRAN libraries are in slightly peculiar places, you should
also look at <code>LD_LIBRARY_PATH</code> or your system's equivalent to make
sure that all libraries are on this path.
<p>You must set whatever compilation flags (if any) are needed to ensure
that FORTRAN <code>integer</code> is equivalent to a C <code>int</code> pointer and
FORTRAN <code>double precision</code> is equivalent to a C <code>double</code>
pointer. This is checked during the configuration process.
<p>Some of the FORTRAN code makes use of <code>COMPLEX*16</code> variables, which
is a FORTRAN 90 extension. This is checked for at configure
time<a rel="footnote" href="#fn-4"><sup>4</sup></a>, but you may need to avoid
compiler flags<a rel="footnote" href="#fn-5"><sup>5</sup></a> asserting
FORTRAN 77 compliance.
<p>For performance reasons<a rel="footnote" href="#fn-6"><sup>6</sup></a> you may want to choose a FORTRAN 90/95 compiler.
<p>If you use <code>f2c</code> you may need to ensure that the FORTRAN type
<code>integer</code> is translated to the C type <code>int</code>. Normally
<code>f2c.h</code> contains <code>typedef long int integer;</code>, which will work
on a 32-bit platform but not on a 64-bit platform.
<a name="Compile%20and%20load%20flags"></a>
<h3 class="section">B.5 Compile and load flags</h3>
<p>A wide range of flags can be set in the file <code>config.site</code> or as
configure variables on the command line. We have already mentioned
<dl>
<dt><code>CPPFLAGS</code>
<dd>header file search directory (<code>-I</code>) and any other miscellaneous
options for the C and C++ preprocessors and compilers
<br><dt><code>LDFLAGS</code>
<dd>path (<code>-L</code>), stripping (<code>-s</code>) and any other miscellaneous
options for the linker
</dl>
<p>and others include
<dl>
<dt><code>CFLAGS</code>
<dd>debugging and optimization flags, C
<br><dt><code>MAIN_CFLAGS</code>
<dd>ditto, for compiling the main program
<br><dt><code>SHLIB_CFLAGS</code>
<dd>for shared libraries
<br><dt><code>FFLAGS</code>
<dd>debugging and optimization flags, FORTRAN
<br><dt><code>MAIN_FFLAGS</code>
<dd>ditto, for compiling the main program
<br><dt><code>SHLIB_FFLAGS</code>
<dd>for shared libraries
<br><dt><code>MAIN_LDFLAGS</code>
<dd>additional flags for the main link
<br><dt><code>SHLIB_LDFLAGS</code>
<dd>additional flags for linking the shared libraries
</dl>
<p>Library paths specified as <code>-L/lib/path</code> in <code>LDFLAGS</code> are
collected together and prepended to <code>LD_LIBRARY_PATH</code> (or your
system's equivalent), so there should be no need for <code>-R</code> or
<code>-rpath</code> flags.
<p>To compile a profiling version of R, one might for example want to
use <code>MAIN_CFLAGS=-pg</code>, <code>MAIN_FFLAGS=-pg</code>,
<code>MAIN_LDFLAGS=-pg</code> on platforms where <code>-pg</code> cannot be used
with position-independent code.
<p><strong>Beware:</strong> it may be necessary to set <code>CFLAGS</code> and
<code>FFLAGS</code> in ways compatible with the libraries to be used: one
possible issue is the alignment of doubles, another is the way
structures are passed.
<a name="Building%20the%20GNOME%20interface"></a>
<h3 class="section">B.6 Building the <small>GNOME</small> interface</h3>
<p>This interface is experimental and incomplete. It provides a console
and two graphics devices named <code>gtk()</code> and <code>gnome()</code>. The
console offers a basic command line editing and history mechanism, along
with tool and button bars that give a point-and-click interface to some
R commands. Many of the features of the console are currently
stubs. The <code>gtk()</code> graphics device is a port of the <code>x11()</code>
device to <small>GDK</small> (the GIMP Drawing Kit). The <code>gnome()</code>
device uses the <small>GNOME</small> canvas.
<p>Due to its experimental nature, the <small>GNOME</small> interface for R
will not be built automatically. You must specify it by running
configure with the <code>--with-gnome</code> option. For example, you might
run
<pre class="smallexample"> ./configure --with-gnome
</pre>
<p>but please check you have all the requirements first. You need at least
the following libraries (or later) installed
<pre class="smallexample"> audiofile-0.2.1
esound-0.2.23
glib-1.2.10
gtk+-1.2.10
imlib-1.9.10
ORBit-0.5.12
gnome-libs-1.4.1.2
libxml-1.8.16
libglade-0.17
</pre>
<p>It is preferable to have a complete installation of the <small>GNOME</small>
desktop environment. If you use Linux, then this should be provided
with your distribution. In addition, packaged binary distributions of
GNOME are available from <a href="http://www.ximian.com">http://www.ximian.com</a> for the most
popular Linux distributions and for Solaris.
<p>Remember that some package management systems (such as <small>RPM</small> and
deb) make a distinction between the user version of a package and the
developer version. The latter usually has the same name but with the
extension <code>-devel</code>. If you use a pre-packaged version of
<small>GNOME</small> then you must have the developer versions of the above
packages in order to compile the R-GNOME interface.
<p>The full list of <small>GNOME</small> options to configure is
<dl>
<dt><code>--with-gnome</code>
<dd>use <small>GNOME</small>, or specify its prefix [no]
<br><dt><code>--with-gnome-includes=</code><var>DIR</var><code></code>
<dd>specify location of <small>GNOME</small> headers
<br><dt><code>--with-gnome-libs=</code><var>DIR</var><code></code>
<dd>specify location of <small>GNOME</small> libs
<br><dt><code>--with-libglade-config=</code><var>LIBGLADE_CONFIG</var><code></code>
<dd>specify location of <code>libglade-config</code>
</dl>
<a name="Platform%20notes"></a>
<h3 class="section">B.7 Platform notes</h3>
<p>This section provides some notes on building R on different Unix-like
platforms. These notes are based on tests run on one or two systems in
each case with particular sets of compilers and support libraries.
Success in building R depends on the proper installation and functioning
of support software; your results may differ if you have other versions
of compilers and support libraries.
<a name="MacOS%20X"></a>
<h3 class="subsection">B.7.1 MacOS X</h4>
<p>You can build R as a Unix application on MacOS X. You will need the
DevTools, <code>f2c</code> or <code>g77</code>, and the <code>dlcompat</code>
library. You will also need to install an X sub-system or configure
with <code>--without-x</code>.
<p><code>f2c</code>, <code>g77</code>, the <code>dlcompat</code> library, and X server
and support libraries are available from the Fink project
(<a href="http://fink.sourceforge.net">http://fink.sourceforge.net</a>). At the time of writing
<code>f2c</code> and <code>g77</code> were not available as part of the Fink
binary distribution and needed to be installed directly; for example for
<code>g77</code> use
<pre class="smallexample"> fink install g77
</pre>
<p>The <code>vecLib</code> library of MacOS >= 10.2.2 can be used <em>via</em> the
configuration options
<pre class="smallexample"> --with-blas="-framework vecLib" --with-lapack
</pre>
<p>to provide higher-performance versions of the BLAS and LAPACK routines.
With <code>gcc 3.1</code> that appears to be the only way to build R, as
the Fortran support routines in <code>libg2c</code> cannot be linked into a
dynmaic library. (We have had reports of success with pre-release
versions of <code>gcc 3.3</code>.)
<a name="Solaris"></a>
<h3 class="subsection">B.7.2 Solaris on Sparc</h4>
<p>R has been built successfully on Solaris 8 aka Solaris 2.8 aka SunOS
5.8 using <code>gcc</code>/<code>g77</code> and the SunPro WorkShop 6 (aka
Forte 6) compilers and the `Sun ONE Studio 7 Compiler Suite' (aka Forte
7), and less regularly on Solaris 2.5.1, 2.6, 2.7 and 9. GNU
<code>make</code> is needed prior to Solaris 2.7 for building other than in
the source tree, and perhaps even then.
<p>The Solaris versions of several of the tools needed to build R
(e.g. <code>make</code>, <code>ar</code> and <code>ld</code>) are in
<code>/usr/ccs/bin</code>, so if using those tools ensure this is in your
path.
<p><code>gcc</code> 3.2.1 and 3.2.2 generate incorrect code on 32-bit Solaris
builds with optimization, but versions 3.1, 3.2, 3.2.3 and 3.3 work
correctly. At least files <code>src/main/engine.c</code>,
<code>src/main/graphics.c</code> and <code>src/modules/devX11.c</code> are affected.
<p>If using <code>gcc</code>, do ensure that the compiler was compiled for the
version of Solaris in use. (This can be ascertained from <code>gcc
-v</code>.) <code>gcc</code> makes modified versions of some header files, and
so (for example) <code>gcc</code> compiled under Solaris 2.6 will not
compile R under Solaris 2.7. Also, do ensure that it was compiled
for the assembler/loader in use. If you download <code>gcc</code> from
<a href="http://www.sunfreeware.com">http://www.sunfreeware.com</a> then you need to download
<code>binutils</code> too. To avoid all these pitfalls we strongly
recommended you compile <code>gcc</code> from the sources yourself.
<p>When using the SunPro compilers do <em>not</em> specify <code>-fast</code>, as
this disables <small>IEEE</small> arithmetic and <code>make check</code> will
fail. The maximal set of optimization options known to work is
<pre class="smallexample"> -xlibmil -xO5 -dalign
</pre>
<p>We have found little performance difference between <code>gcc</code> and
<code>cc</code> but considerable benefit from using a SunPro Fortran
compiler: the <code>gcc</code>/<code>f77</code> combination works well. For
many C++ applications (e.g. package <strong>Matrix</strong>) Forte 7 requires
<code>-lCstd</code>, which the configure script will add to
<code>SHLIB_CXXLDFLAGS</code> if it identifies the compiler correctly.
<p>To compile for a 64-bit target on Solaris (which needs an UltraSparc
chip and for support to be enabled in the OS) with the Forte 6 and 7
compilers we used
<pre class="smallexample"> CC="cc -xarch=v9"
CFLAGS="-xO5 -xlibmil -dalign"
F77="f95 -xarch=v9"
FFLAGS="-xO5 -xlibmil -dalign"
CXX="CC -xarch=v9"
CXXFLAGS="-xO5 -xlibmil -dalign"
</pre>
<p>in <code>config.site</code>.
<p>For 64-bit compilation with <code>gcc</code> 3.2.x we used
<pre class="smallexample"> CC="gcc -m64"
FFLAGS="-m64 -g -O2"
CXXFLAGS="-m64 -g -O2"
LDFLAGS="-L/usr/local/lib/sparcv9 -L/usr/local/lib"
</pre>
<p>Note that using <code>f95</code> allows the Sun
performance library <code>libsunperf</code> to be selected: it will not work
with <code>f77</code>, nor with <code>g77</code>. <code>libsunperf</code>
contains both BLAS and LAPACK code, and <code>--with-lapack</code> is
recommended for 32-bit builds using <code>f95</code>, but not for
64-bit builds where on our test system it failed in both Forte 6U1 and
7, albeit in different ways. Our experience has been that ATLAS's BLAS
is faster than <code>libsunperf</code>, especially for complex numbers.
<p>Some care is needed to ensure that libraries found by
<code>configure</code> are compatible with the R executable and modules, as
the testing process will not detect many of the possible problems. For
32-bit builds under <code>cc</code> the flag <code>-dalign</code> is needed for
some of the Sun libraries: fortunately the equivalent flag for
<code>gcc</code>, <code>-mno-unaligned-doubles</code>, is the default. In theory,
libraries such as <code>libpng</code>, <code>libjpeg</code>, <code>zlib</code> and the
ATLAS libraries need to be built with a <code>pic</code> or <code>PIC</code> flag,
which could be a problem if static libraries are used. In practice this
seems to give little problem for 32-bit builds.
<p>For a 64-bit build, 64-bit libraries must be used. As the configuration
process by default sets <code>LDFLAGS</code> to <code>-L/usr/local/lib</code>,
you may need to set it to avoid finding 32-bit addons (as in the
<code>gcc -m64</code> example above).
<a name="HP-UX"></a>
<h3 class="subsection">B.7.3 HP-UX</h4>