One thing that was great was the ability to copy to and from the clipboard:
and
This makes getting data in from and to excel particularly quick. Good if you want to do a speedy analysis and dont want to set up a more permanent structure.
R and Excel
We showed in a little spreadsheet how you can embed R functions in Excel.
To run this example you need the R-Excel Addin, from here. Please read the documentation that comes along with the Addin and see the examples as well.
The key idea is, that you write a little warpper in VB around your R code.
Open the Visual Basic editor (press Alt F11 while in Excel) and go to ThisWorkbook and copy and paste
Private Sub Workbook_Open()
Call RInterface.StartRServer
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call RInterface.StopRServer
End Sub
into it.
This will open the R server in the background whenever you open the workbook and the second procedure will stop the R server when you close the workbook.
You have to make a reference to the "RExcelVBAlib" (goto Tools\References... and tick RExcelVBAlib) so Excel knows those functions.
In a new module we create now our RExcel function. Let's reinvent the wheel and programm the "SUM" function again:
Function rSum(Helmut As Range) As Variant
Call Rput("rHelmut", Helmut)
Call RInterface.RRun("X<-sum(rHelmut)")
rSum = reval("X")
End Function
That's it! You can use rSum now in the same way as the SUM function of Excel.
Here is a spreadheet containing the example of this site.