Using R Inside Microsoft Excel

If you’re familiar with Microsoft Excel, or if you work with a lot of data files in Excel format, you might want to run R directly from inside Excel. The RExcel software lets you do just that (on Microsoft Windows systems). You can find information about this software at http://rcom.univie.ac.at/. This site also includes a single installer that will install R plus all the other software you need to use RExcel.

If you already have R installed, you can install RExcel as a package from CRAN. The following set of commands will download RExcel, configure the RCOM server, install RDCOM, and launch the RExcel installer:

> install.packages("RExcelInstaller", "rcom", "rsproxy")
> # configure rcom
> library(rcom)
> comRegisterRegistry()
> library(RExcelInstaller)
> # excecute the following command in R to start the installer for RDCOM
> installstatconnDCOM()
> # excecute the following command in R to start the installer for REXCEL
> installRExcel()

Follow the prompts within the installer to install RExcel.

After you have installed RExcel, you will be able to access RExcel from a menu item. If you are using Excel 2007, you will need to select the “Add-Ins” ribbon to find this menu as shown in Figure 2-4. To use RExcel, first select the R Start menu item. As a simple test, try doing the following:

  1. Enter a set of numeric values into a column in Excel (for example, B1:B5).

  2. Select the values you entered.

  3. On the RExcel menu, go to the item “Put R Var” > “Array.”

  4. A dialog ...

Get R in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.