[Rcom-l] R Graphics
Dear Users I need visual basic in front end and R in background. For this I installed R-(D)COM server http://www.sciviews.org/_rgui/projects/RDcom.html. I am developing for winXP OS. Is this the best option? I have successfully implemented in data transfer part, but I have some query to graphics part. Consider the example RSrv250S\Server\samples\Graphics The StatConnectorGraphicsDevice control is working fine but image quality is not so good. This may be due to window size default is (7,7) in R – I, guess _ Dim sconn As StatConnector Dim gfxdev As ISGFX Set sconn = New StatConnector sconn.Init R Set gfxdev = Gfx1.GetGFX sconn.AddGraphicsDevice dev1, gfxdev sconn.EvaluateNoReturn plot(sin(1:10)) sconn.Close ___ *I tried to change window size by* sconn.AddGraphicsDevice dev1, gfxdev *sconn.EvaluateNoReturn windows(4,4)* sconn.EvaluateNoReturn plot(sin(1:10)) But this has no effect, rather this cause a *new R graphics* window to popup. I thought of using a image control instead of the StatConnectorGraphicsDevice control. I use ' Dim sconn As StatConnector Set sconn = New StatConnector sconn.Init R * sconn.EvaluateNoReturn windows(4,4)* sconn.EvaluateNoReturn plot(sin(1:10)) *conn.EvaluateNoReturn savePlot(file=, type = wmf)* sconn.Close *IN VB** * *Image1.Picture = Clipboard.GetData(vbCFMetafile)* * * *'* This is working fine with popup of R graphic window. I want to get this done in background. There may be simple solution to keep R graphics window silent, I am not able to do this. Any help on this matter is appreciated -- Jagadish Prasad Patra Research Scholar Agricultural Food Engineering Department IIT Kharagpur India http://jagadish.patra.googlepages.com ___ Rcom-l mailing list Rcom-l@mailman.csd.univie.ac.at http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l More information (including a Wiki) at http://rcom.univie.ac.at
Re: [Rcom-l] R Graphics
The latest version of RExcel has Insert current R plot on the context menu. This is only available if an R plor exists, of course. You can check the source code to see how it is implemented. It does some trickery about colors and frames. On Nov 18, 2008, at 1:16 PM, Vilmos Prokaj wrote: Hi, I dont know wether this the good solution for you or not, but for your last idea I thought of using a image control instead of the StatConnectorGraphicsDevice control. Dim sconn As StatConnector Set sconn = New StatConnector sconn.Init R * sconn.EvaluateNoReturn windows(4,4)* sconn.EvaluateNoReturn plot(sin(1:10)) *conn.EvaluateNoReturn savePlot(file=, type = wmf)* sconn.Close *IN VB** *Image1.Picture = Clipboard.GetData(vbCFMetafile)* the following can help. There is a win.metafile device in R which writes directly to file (or clipboard if filename is ) so your code should be like this sconn.EvaluateNoReturn win.metafile(,4,4) sconn.EvaluateNoReturn plot(sin(1:10)) sconn.EvaluateNoReturn dev.off() and finally Image1.Picture = Clipboard.GetData(vbCFMetafile) I did not test this last line. I used Ctrl-V on an Excel worksheet, and it worked, so the image is copied to the clipboard by the above method. -- Vilmos Prokaj Eötvös Loránd University, Department of Probability and Statistics Pázmány Péter sétány 1/C Budapest, 1117 Hungary e-mail:[EMAIL PROTECTED] ___ Rcom-l mailing list Rcom-l@mailman.csd.univie.ac.at http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l More information (including a Wiki) at http://rcom.univie.ac.at -- Erich Neuwirth Didactic Center for Computer Science and Institute for Scientific Computing University of Vienna ___ Rcom-l mailing list Rcom-l@mailman.csd.univie.ac.at http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l More information (including a Wiki) at http://rcom.univie.ac.at
Re: [Rcom-l] R Graphics
Hi, I dont know wether this the good solution for you or not, but for your last idea I thought of using a image control instead of the StatConnectorGraphicsDevice control. Dim sconn As StatConnector Set sconn = New StatConnector sconn.Init R * sconn.EvaluateNoReturn windows(4,4)* sconn.EvaluateNoReturn plot(sin(1:10)) *conn.EvaluateNoReturn savePlot(file=, type = wmf)* sconn.Close *IN VB** *Image1.Picture = Clipboard.GetData(vbCFMetafile)* the following can help. There is a win.metafile device in R which writes directly to file (or clipboard if filename is ) so your code should be like this sconn.EvaluateNoReturn win.metafile(,4,4) sconn.EvaluateNoReturn plot(sin(1:10)) sconn.EvaluateNoReturn dev.off() and finally Image1.Picture = Clipboard.GetData(vbCFMetafile) I did not test this last line. I used Ctrl-V on an Excel worksheet, and it worked, so the image is copied to the clipboard by the above method. -- Vilmos Prokaj Eötvös Loránd University, Department of Probability and Statistics Pázmány Péter sétány 1/C Budapest, 1117 Hungary e-mail:[EMAIL PROTECTED] ___ Rcom-l mailing list Rcom-l@mailman.csd.univie.ac.at http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l More information (including a Wiki) at http://rcom.univie.ac.at
Re: [Rcom-l] R Graphics using VBA
Roger, I would like to use R graphics in my VBA application. In particular, I want to display something similar to Fig. 3 in your article Excel::COM::R (Computational Statistics, 2007). It seems that the R graphics is displayed in an Excel form with Active X controls. Would it be possible to get the code for this or at least some hints on how to do it. Use GraphicsDevice from StatConnControls, put it on a form, bind the control to the StatConnector instance and then it will work. Sample code (for VB6) can be found in the VB6Devices sample in the Tutorial sources from UseR! 2006 on rcom.univie.ac.at. The control on the bottom of the form is the one you should use in VBA. Another issue that the article raises is that if the COM server is on a remote machine then the graphics will also be shown on that machine. Your solution to this is to provide an Active X control. Although I am familiar with Excel Active X controls, I can't work out how to do this. If you are using the ActiveX control, the graphics will show on the machine where the ActiveX is shown, no matter if R is running locally ore remotely. -- Thomas Baier ___ Rcom-l mailing list Rcom-l@mailman.csd.univie.ac.at http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l More information (including a Wiki) at http://rcom.univie.ac.at