[R] Creating Excel-Charts via RDCOMClient

Erich Neuwirth erich.neuwirth at univie.ac.at
Sat Jun 27 15:23:21 CEST 2009


The statconn tools allow you configure your application
with the Excel client on one machine and the R server
on another machine. In (D)COM, the D stands for
distributed COM.



Dr. Michael Wolf wrote:
> Hi R-users!
> 
> I'm trying to create an easy Excel chart using the package RDCOMClient. The
> following example is working fine:
> 
> #-------------------------------------------------------------------
> library(RDCOMClient)
> 
> xlLocationAsObject <-2
> xlXYScatterSmoothNoMarkers <- 73
> 
> ex <- COMCreate("Excel.Application")
> wb <- ex[["Workbooks"]]$Add()
> sh <- ex$ActiveSheet()
> ex[["Visible"]] <- TRUE
> 
> r <- sh$Range("A1:D1")
> r[["Value"]] <- c(1:4)
> 
> ch <- ex$Charts()
> ch$Add()
> ac <- ex$ActiveChart()
> ac[["ChartType"]] <- xlXYScatterSmoothNoMarkers
> ac$Location(Where=xlLocationAsObject, Name="Tabelle1")
> ac$SeriesCollection()$NewSeries()
> ac$SeriesCollection(1)[["XValues"]] <- r
> ac$SeriesCollection(1)[["Values"]] <- r
> #-------------------------------------------------------------------
> 
> But I don't perfer this way writing calculated values like "c(1:4)" to the
> Excel Sheet and calling them via "SeriesCollection". I'm looking for direct
> adressing to "SeriesCollection". But codes like
> 
> ac$SeriesCollection(1)[["XValues"]] <- asCOMArray(c(1:4))
> ac$SeriesCollection(1)[["Values"]]  <- asCOMArray(c(1:4))
> 
> were not successfull. E.g. the code above produces the error message "OLE
> error 0x800a01a8".
> 
> Ok, I know that there are better ways to solve my problem by using the
> RExcel/statconn tools. Unfortunately the conditions under which I work
> (partly using other computers by adressing R on my working computer) permit
> the use of these tools. As I see, my best chance is a solution with
> RDCOMClient. (A clipboard solution which I developed some month ago are very
> slow when using large data matrices.)
> 
> So, could anyone help me solving the problem?
> 
> Thanks,
> 
> Michael Wolf
> Von-Schonebeck-Ring 18
> D-48161 Muenster
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459




More information about the R-help mailing list