########################################################
# I User’s Guide 9
# 2 Installation 10
# 2.1 Windows . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . 11
# 2.2 MacOS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
# 2.3 UNIX and Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
# 2.4 Version Compatability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
########################################################
2.3 UNIX and Linux
Installing R
# 一般来说,用UNIX和Linux的往往都是高级用户,不用我在此现丑,把原文帧出,以供参考。
Type R at the terminal prompt (which we denote as % in this section) to see if R is available. (Typing q() will enable you to quit.) If it is installed, proceed to the next section. If it is not installed and you are not the administrator, contact that individual, kindly request that they install R on the server, and continue to the next section. If you have administrator privileges, you may download the latest release at the CRAN website. Although installation varies according to your Linux distribution, we provide an example for Red Hat Linux 9.0 as a guide:
1. Log in as root.
2. Download the appropriate binary file for Red Hat 9 from CRAN. For example, for Red Hat 9 running on the Intel 386 platform, go to
http://cran.r-project.org/bin/ linux/.
3. Type the following command at the terminal prompt:
% rpm -ivh R-2.3.1-1.i386.rpm
Installing Zelig
Before installing Zelig, you need to create a local R library directory. If you have done so already, you can skip to Section 2.3. If not, you must do so before proceeding because most users do not have authorization to install programs globally. Suppose we want the directory to be ~/.R/library. At the terminal prompt in your home directory, type:
% mkdir ~/.R ~/.R/library
Now you are ready to install Zelig. There are two ways to proceed.
1. Recommended procedure:
(a) Open the ~ /.Renviron file (or create it if it does not exist) and add the following line:
R_LIBS = "~/.R/library"
You only need to perform this step once.
(b) Start R. At the R prompt, type:
> source("
http://gking.harvard.edu/zelig/install.R")
> library(Zelig)
(You may ignore the warning messages, unless they say “Non-zero exit status”.)
(c) Alternatively, you can avoid the warning messages by installing each component package separately and specifying the installation path:
> install.packages("Zelig", lib = "~/.R/library")
> install.packages("MCMCpack", lib = "~/.R/library")
> install.packages("coda", lib = "~/.R/library")
> install.packages("VGAM", lib = "~/.R/library")
> install.packages("zoo", lib = "~/.R/library")
> install.packages("sandwich", lib = "~/.R/library")
> library(Zelig)
(d) Finally, create a .Rprofile file in your home directory, containing the line:
library(Zelig)
This will load Zelig every time you start R.
2. Alternatively:
(a) Add the local R library directory that you created above (~ /.R/library in the example) to the environmental variable R LIBS.
(b) Download the latest bundles for Unix from the Zelig website, and (for the VGAM, MCMCpack, coda, sandwich, and zoo packages) from the CRAN website.
(c) If XX is the current version number, at the terminal prompt, type:
% R CMD INSTALL Zelig_XX.tar.gz
% R CMD INSTALL MCMCpack_XX.tar.gz
% R CMD INSTALL coda_XX.tar.gz
% R CMD INSTALL VGAM_XX.tar.gz
% R CMD INSTALL zoo_XX.tar.gz
% R CMD INSTALL sandwich_XX.tar.gz
% rm Zelig_XX.tar.gz VGAM_XX.tar.gz zoo_XX.tar.gz sandwich_XX.tar.gz
(d) Create a .Rprofile file in your home directory, containing the line:
library(Zelig)
This will load Zelig every time you start R.
Zelig is distributed under the GNU General Public License, Version 2. After installation, the source code is located in your R library directory. If you followed the example above, this is /.R/library/Zelig/.
Updating Zelig
There are two ways to update Zelig.
1. We recommend that you start R and, at the R prompt, type:
> update.packages()
2. Alternatively, you may remove an old version by command by typing R CMD REMOVE Zelig at the terminal prompt. Then download and reinstall the package using the installation procedure Section 2.3 outlined above.
2.4 版本的兼容性
除了R本身外,Zelig也依赖于其它几个由其他开发团队维护的R程序包(PKG)。尽管我们努力来保持最新版本的Zelig直到最新的那些包的版本,这还是有可能会发生不兼容性的问题。见附录B.1的包的检测列表中与发行的Zelig兼容的包。你可以在
http://www.r-project.org获得大多数包的先前版本。
# 或自己把兼容的包先存一份在自己的机器中。
<未完待续,下一章接着用中文解释>