Table of Contents
Installation of R, R(D)COM server and RExcel
R needs to be installed on the machine. The current version of the statconn tools and RExcel need R version 2.15.1 or higher.
R needs to be installed with the SDI display option (you are prompted for using either SDI or MDI during the installation of R). And you also need to tell R to write its registry entries during installation (you are prompted for that also).
There is a way of simplifying the installation:
Download the R installation program (currently this is
R-3.1.1-win.exe) from a CRAN mirror.
Create a text file name
rinst.inf with the following content.
[Setup] Lang=en Dir=C:\Program Files\R\R-3.1.1 Group=R NoIcons=0 SetupType=user Components=main,i386,x64,translations Tasks=desktopicon,recordversion,associate [R] MDISDI=SDI HelpStyle=HTML Internet=Standard
And create a file
Rexeinst.bat with the following content
You can downlaod a zip file containing the 2 files mentioned above from here
Put all three files (the installer exe, the .inf file and the .bat file) in the same directory.
In file manager, double click the file
This should start the installation process with the defaults we need set.
How to install RExcel when R is already installed
Assuming you have a suitable version of R installed, the following steps are necessary to install RExcel and the infrastructure. You need to be logged into Windows with administrator privileges to do this!
You also need to follow these instructions if you upgrade R, i.e. you install a new release of R after you have installed RExcel.
- Download the statconn DCOM server and execute the program you downloaded
- Start R as administrator (on Windows 7 you need to right-click the R icon and click the corresponding item)
- In R, run the following commands (you must start R as administrator to do this)
install.packages(c("rscproxy","rcom"),repos="http://rcom.univie.ac.at/download",lib=.Library) library(rcom) comRegisterRegistry()
Now you have rcom installed, but RExcel is not installed yet.
To install RExcel: download the RExcel installer and run this installation program. Installing RExcel this way will set the background server of R as the default R server for RExcel. You can change this in the configuration settings in R. If you want to set the foreground server as the default site wide server, there is an appropriate option in one of the dialogs of the installation.
If you do not install RExcel and want the package
rcom to be loaded
into R each time you start it, you have to add the line
Rprofile.site (usually found in
C:\Program Files\R\R-3.0.2\etc\i386). You have to start your editor as administrator
to be able to modify this file.
Rcmdr and RExcel
It is necessary to install Rcmdr 2.0-1 or later from CRAN. To do this, start R as administrator and run
It is very important to run the command
library(Rcmdr. when started for the first time, Rcmdr will
download and install further packages, and this does not work when Rcmdr is started from within RExcel.
R will prompt you to install further packages required by Rcmdr. Let R install all these packages.
Now, RExcel can work with Rcmdr (and can be started from within RExcel).
R through Excel book example files
If you also want to install the example files from the book R through Excel by Heiberger and Neuwirth, do the following
- Install the package
Rcmdras described in the previous section
- Install the package
RcmdrPlugin.mosaicfrom CRAN. These will automatically install additional packages. To do so, run the following commands in R (start R as Administrator):
install.packages(c("RcmdrPlugin.mosaic","ENmisc"), lib=.Library, dependencies=TRUE)
- Then, download the book example files installer RthroughExcelWorkbookInst.latest.exe
and run it. This will install the workbook examples.
The computer you are using needs to be connected to the internet during the entire installation sequence above.
To run R as administrator you do not have to do anything special on Windows XP if
you are already logged as a user with administrator privileges. Otherwise, and also if you are running Windows Vista or Windows 7, you have to right-click the icon starting R (on the desktop or in the
Start → All Programs → R menu) and then select
Run as Administrator. You will be prompted for the administrator password, and then R will
run with administrator privileges.
The user who installed RExcel using
RExcelInstaller will have an RExcel menu item on the Excel menu.
Other users on a machine with RExcel already installed who did not use
RExcelInstaller need to do the following:
On the Start menu under
Programs → R → RExcel there are so.e items:
Activate RExcel or
Activate RExcel2007 or
Activate RExcel2013. Clicking these menu items
will install the RExcel menu on the Excel menu bar for the current user.
If you are not an experienced R user and did not install
the Heiberger-Neuwirth example workbooks, it might be helpful to additionally install
Rcmdr which will give you pull down menus to important
R function. This menu can become completely integrated into the Excel menu bars.
This setup allows you to interact with R from Excel and also allows you to type commands on the R command line interface (usually Rgui).
(You might want to load a set of R packages every time either (1) when R starts up or (2) when RExcel accesses R.
To do it in when run starts up just add the appropriate
library command to your
Rprofile.site file. Be sure you have Administatrive privileges while doing this (as described previously on this page). Alternately, to do it when RExcel accesses R they can be placed in
C:\Program Files\RExcel\xls\RExcelStart.R which is a file that RExcel runs before starting or accessing R. In any case note that the
library(rcom) command cannot be placed in
RexcelStart.R and must be in
Rprofile.site -gg). Of course, R packages also can be loaded later, and this can be done either
from Rgui, RCommander, or by sending the appropriate library command directly from Excel using one of the RExcel mechanisms.
Uninstalling RExcel. Go to the Control Panel and in Vista click Uninstall a Program (under Programs) to get to the uninstall screen and use that. In Windows XP, use the
Add or Remove Programs item on the Control Panel.
The rcom setup we just described is a complete solution for using R and Excel together. There is another setup option also. The statconnDCOM server also works with RExcel directly. For the user the main difference is that using this server (called background server in the RExcel server setup dialog) you will not be able to access the R command line interface directly. One of the reasons for this package is that it allows to create statistics applications residing within Excel using R in way that the end user never gets any hint that R is in use. It is the foundation for statistics application with R as the user interface toolkit. To install it, you can download the the server from out web site.
This server is installed automatically if you do a full installation of
the R package
rcom from CRAN.
When RExcel is installed, it will find this server and allow you to configure the background server to use the (D)COM server.
This introduction only describes the first step to get you up and running. It is by no means complete. There are a few more usage scenarios. Everything is described int the documentation coming with the packages. All the package also include many examples demonstrating different techniques to use the facilities implemented by our tool and packages.