Full records of R compilation and installation in Ubuntu
It is very convenient to install R in Ubuntu. You can search for r-base in the software management center for direct installation, or add the CRAN directory to the source, and then install it through apt-get:
Sudo apt-get install r-base
If you want to clearly understand the details in the rinstallation process and control the relevant settings, You can manually compile .tar.gz for installation.
First, you need to download the R source code package on CRAN (use the wget command to download: wget url.pdf, and I use the latest version r-3.1.0.orig.tar.gz. Import it to a directory and decompress it:
Tar-zvxf R-3.1.0.orig.tar.gz
Then go to the directory R-3.1.0, run./configure to check the installed dependency environment and configure the installation file:
./Configure -- prefix =/home/me/R -- enable-R-shlib
Note that the prefix parameter can be used to set the path where R will be installed. enable-R-shlib can ensure that dynamic libraries under the lib directory can be shared. Do not forget to add this option, otherwise, an Error in dyn may occur when some packages are installed later. load error.
The system will prompt that the G77 compiler error is not found and a gfortran must be installed. Of course, the g77 compiler can be successfully installed, but the new version of Ubuntu does not provide the g77 source, the old aptitude method needs to be configured, and some new R Packages may fail to be compiled using g77, so it is safer to use the new gfortran method. In addition, you must install build-essential to provide a C/C ++ compiling environment. Otherwise, an error is reported.
Sudo apt-get install build-essential
Sudo apt-get install gfortran
If an error occurs: configure: error:-with-readline = yes (default) and headers/libs are not available, you need to install the libreadline6-dev:
Sudo apt-get install libreadline6-dev
If an error occurs: configure: error:-with-x = yes (default) and X11 headers/libs are not available, you must install libxt-dev:
Sudo apt-get install libxt-dev
After all the dependent packages are installed, the configuration is successful, and the compilation is successful:
Make
Make install
After installation, You need to manually set the environment variables. You can open the. bashrc file, add the R_HOME and R_LIBS variables, and modify the PATH, so that R is fully installed.