How can I access Windows COM objects in R v3?

com, r

Solution

I looked at the rcom source code a few months ago. It seems I can get it to build and install OK on R3.0.1. Below is the procedure if it helps.

- Get a checkout of the latest source code of rcom. I have rcom_2.2-5.tar.gz locally. I can google something at the following address, but I have no idea of the provenance, so up to you to check it is legit. http://cran.open-source-solution.org/web/packages/rcom/index.html

- in R do `install.packages('rscproxy')`

- install Rtools as per the instructions on the R web site (http://cran.r-project.org/bin/windows/Rtools),

- open a Windows command prompt i.e. run "CMD"

go to the folder containing the 'rcom' folder, and at the command prompt:

set R="c:\Program Files\R\R-3.0.1\bin\i386\R.exe"
%R% CMD check --no-manual rcom

check it passes without too many complaints. Your call as to the --no-manual option (if you have MiKTeX installed you may remove it)

%R% CMD INSTALL rcom

should result in

    installing to c:/Rlib/rcom/libs/i386
    ** R
    ** inst
    ** preparing package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
    rcom requires a current version of statconnDCOM installed.
    To install statconnDCOM type
         installstatconnDCOM()
    This will download and install the current version of statconnDCOM
    You will need a working Internet connection
    because installation needs to download a file.
    * DONE (rcom)

in R:

library(rcom)
installstatconnDCOM()

I tried a `comRegisterRegistry() ; comRegisterServer() ; x<-comGetObject("Excel.Application")` but I get a NULL for `x`. I am not a user of rcom so while it all seems to compile fine; it may just not work anymore.

If you happen to need to access .NET code, a viable option (and yes I have a vested interest in mentioning it) may be the rClr package.

Hope this helps; I'd be interested to hear how you go.

Problem

Some time ago, you used to be able to install the `rcom` package in R to use COM scripting (eg, access to external programs.) Unfortunately, it seems to be discontinued: Package ‘rcom’ was removed from the CRAN repository. Formerly available versions can be obtained from the archive. This depends on statconnDCOM, which nowadays restricts use, contrary to the CRAN policy for a package with a FOSS licence. See http://rcom.univie.ac.at/ and http://www.statconn.com/. Following the archive and statconn links and installing one of the older versions in R version 3 gives the error: “Error: package ‘rcom’ was built before R 3.0.0: please re-install it”. I am not very familiar with R, but there seems no way around this message - after all, it occurs when installing, so re-installing doesn't seem to be the answer. It appears as though `rcom` is simply not available for recent (3.0+) versions of R. I have also scanned the package list, although searching for "COM" there returns over a hundred results and it is possible I missed the right one when clicking through them. How can I use the `rcom` package, or use COM from within R some other way? (Note: I am asking this question on behalf of a colleague. I have no experience with R myself at all. Both of us, when searching for answers, could not find anything. I am sure that others are also using COM in the latest version of R, though!)

Original source

Related problems