Excelsi-R comes in two parts: an Excel add-in and an R package. You must be running Windows to install the add-in, but (parts of) the package will work under other operating systems such as Linux.
To install, first run the installer setup.exe file. Then in Excel and enable the Excelsi-R.xla Add-in. For instance, if you used Excel 2010 and installed Excelsi-R to your C:\Program Files\Excelsi-R
directory, you would open Excel and then select File->Options->Add-Ins->Manage Excel Add-ins Go->Browse and then select
C:\Program Files\Excelsi-R\Excelsi-R.xla
After that, close Excel and restart it. You should now see Connect to R and Disconnect From R buttons on your Add-ins command bar.
To install the ExcelsiR R package, first install the prerequisites Cairo and png packages from CRAN. The ExcelsiR package itself is not on CRAN, so you need to install it manually for now. You can do this by running this command from your R console:
install.packages("c:\\path_to_file\\ExcelsiR_0.6.tar.gz", repos=NULL, type="source")
where "c:\\path_to_file" should be replaced by the directory that the ExcelsiR package file is in. Note you need double backslashes under Windows because the single backslash \ is the R string escape character.
Before you can use any R functions, you need to connect to a running R server. Currently only local operation is supported. So start R the way you would normally on your computer. At the prompt, type in
library(Rserve) Rserve()
If you get an error about Rserve not being found, you need to install the Rserve package by typing install.packages("Rserve")
.
Once Rserve is running, you should be able to connect to R and disconnect from R by pressing those buttons on your Add-ins command bar.
Excelsi-R has the ability to connect to a remote Rserver. However, for security reasons Rserve does not accept remote connections by default. For information on configuring Rserve for remote clients, see the Rserve Documentation. An alternative is to tunnel an Excelsi-R request to a remote computer so it appears as a local connection. For instance, you can connect a windows Excelsi-R client to an Rserve server running on a remote linux machine by using SSH tunneling. Putty SSH is a windows SSH client that supports tunneling.
When setting up Rserve for Excelsi-R, please configure Rserve to use UTF-8 encoding, if you want to use more than 7-bit ASCII. This can be done using the Rserve configuration file, or by passing Rserve the "--RS-encoding utf8" option.
Excelsi-R comes with several templates that illustrate how it can be used. For example:
Local Linear Regression.xlsx - Using R's sm package, do local linear regression on the given data set. Return predictions and plot.
Basic State Maps.xlsx - Produce a map of the US with the states colored as specified.
It may be best to start with those templates and adapt them to your project.
The columns in an Excelsi-R block, except for Action, are optional. They can be in any order because the add-in looks at the header.
If the workbook has a named range called "ExcelsiRSettings", then default settings will be read from that block. The block is assumed to have two column format. The left column contains keys (the settings names); the right columns contains the values (the settings themselves).
Currently there are only two settings:
To display an R graph in an Excel spreadsheet, you need to use the ExcelsiRGraph function on the remote side, provided by the ExcelsiR R package. If you are using the ggplot2 package, you can simply put the plot as the second argument of the function. For instance:
Action | R Code or Variable Name |
---|---|
eval | ExcelsiRGraph("plotname", qplot(rnorm(1000))) |
If you are using another graphics package, you will need to use the ExcelsiRInitGraph function before each graph. For instance:
Action | R Code or Variable Name |
---|---|
exec | ExcelsiRInitGraph() |
exec | plot(1:10) |
eval | ExcelsiRGraph("plot1") |
exec | ExcelsiRInitGraph() |
exec | plot(1:20) |
eval | ExcelsiRGraph("plot2") |