Skip to content
Prev 140028 / 398506 Next

I need help integrating ggplot2 into Excel

Create an R script,name it "Myggplot2" and place it on
your desktop.In excel open the vb editor and write
this code:
Sub Myggplot2()
'start R
Call rinterface.StartRServer
'Put the dataframe into R,assuming that your 
'data is in sheet1 cells A1:D1
Call rinterface.PutDataframe("yourdataframename",
Range("Sheet1!A1:D" & Range("D1").End(xlDown).Row))
Call rinterface.RRun("attach(yourdataframename)")
'dataframe is attached,now run r script
rinterface.RRun "source(""C:/Documents and
Settings/Owner/Desktop/Myggplot2.r"")"
Call rinterface.StopRServer
End Sub

Running code from RExcel you must use print(myplot)at
the end of the code
good luck
RInterface.RRun("qplot(x=Hours,y=pH,data=ds,facets=Sample~.,geom=""line"",group=Cell)")
qplot(x=Hours,y=pH,data=ds,facets=Sample~.,geom=""line"",group=Cell)
______________________________________________
Felipe D. Carrillo
  Fishery Biologist
  Department of the Interior
  US Fish & Wildlife Service
  California, USA