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
Dear all
I use ggplot2 extensively for my plotting routines
and rexcel to have the
best of two worlds. (RExcel v 1.75 and R (D)Com v.
2.5)
I can run my ggplot functions, such as qplot(...),
in scratchpad mode, but
not in Macro nor Worksheet functions mode.
I have tried the following in Macro mode:
Call RInterface.RRun("library(ggplot2)")
...
Call
With no output ...
I have tried the following in Worksheet function
mode:
if Range(H40:I42) contains:
"
(Embedded image moved to file: pic10654.jpg)
"
and Range(H48) contains:
"qplot"
The following call:
=Rcalla(H48;makeargs(H40:I42))
Gives me no output
Scratchpad mode
However, right clicking a cell containing:
and then selecting "Run R" works like a dream!
I would like to develop an excel based GUI for
R-data treatment and
plotting, and I would like to use ggplot2 as my
plotting engine.
What am I doing wrong?
Thank you for your help
Jannik Vindel?v, Ph.D.
Project Manager
Dairy Culture Development
Innovation
P.O. Box 64
Arpajon
Cedex
F-91292
France
Phone: +33 (0)1 6988 3636
Direct Phone: +33 (0)1 6988 3629>