,

General problems and solutions

R(D)COM and rcom do not return results of a function call

R(D)COM and rcom can only return scalar values (e.g. strings) and arrays. Many R functions have R lists as return values. Lists cannot be transferred by R(D)COM and rcom. The solution is to transfer only components of lists which in many cases are arrays.

Example:
zzz←lm(y~x) will return a list of many components and assign it to zzz. zzz then cannot be transferred by R(D)COM and rcom. The regression coefficients of the model are given by the component coefficients of this list. Therefore zzz$coefficients can be transferred by our libraries.
To be on the safe side, one could transfer as.matrix(zzz$coefficients), typecasting the R object to a matrix explicitly before transferring.

Debugging R(D)COM applications

When debugging R(D)COM applications the problem is that one cannot “look into” the state of R to see how data arrived in R and what computations were performed.

There is a way to get more information: Install rcom (available as package from CRAN). rcom works as a library in the command line version of R, and it allows to use R as COM server, and it allows to use the command line for R concurrently with an application accessing R.

After installing the rcom library, it has to be registered by executing

library(rcom)
comRegisterRegistry()

once. From then on, starting R an loading rcom by

library(rcom)

In VBA, a new instance of the (D)COM server is created by

MyServerName = ""
Set My_R = CreateObject("StatConnectorSrv.StatConnector", MyServerName)

alternatively, a new server is created with the rcom library is created by

MyServerName = ""
Set My_R = CreateObject("RCOMServerLib.StatConnector", MyServerName)

The two objects named My_R in the code above behave identically, so code intended to run with R(D)COM can be tested in rcom before production. The advantage is that one can run code chunks with rcom and then go to the command line in the current R process and check what is going wrong in more detail.

Uninstalling an uninstallable version of R 2.12.0 manually

Due to changes in the architecture of R, it is possible that a version of R 2.10.0 installed by RAndFriendsSetup2120-V3.1.9-1.exe might have a broken uninstaller refusing to uninstall R.

If this is the case, here is the solution.

If you are running a 32bit version of windows, create a file named runinst32.reg (in a text editor) and copy the following content into the following.

Windows Registry Editor Version 5.00
; runinst32.reg
; Removes the entries of an uninstallable R 2.12.0 installation
; on 32bit Windows

[HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R]
"InstallPath"=-
"Current Version"=-
[HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R32]
"InstallPath"=-
"Current Version"=-

[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64]

[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R\2.12.0 beta]
[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R\2.12.0]

[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R32\2.12.0 beta]
[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R32\2.12.0]

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\R for Windows 2.12.0 beta_is1]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\R for Windows 2.12.0_is1]

On a 64bit version of Windows, create a file runinst64.reg with the following content.

Windows Registry Editor Version 5.00
; runinst64.reg
; Removes the entries of an uninstallable R 2.12.0 installation
; on 64bit Windows

[HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R]
"InstallPath"=-
"Current Version"=-
[HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R32]
"InstallPath"=-
"Current Version"=-
[HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64]
"InstallPath"=-
"Current Version"=-

[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R\2.12.0 beta]
[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R\2.12.0]

[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R32\2.12.0 beta]
[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R32\2.12.0]

[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64\2.12.0 beta]
[-HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64\2.12.0]

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\R for Windows 2.12.0 beta_is1]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\R for Windows 2.12.0_is1]

You will need administrator privileges to perform the following actions.

Doubleclick the appropriate file (runinst32.reg on 32bit Windows, runinst64.reg on 64bit Windows) You will be prompted to allow changes in the registry.

When this action is completed, delete the directory C\Program Files\R\R-2.12.0 completely. The location of this directory might be slightly different if you installed R in a different place or if you have a nonEnglish version of Windows.

When this action is completed, download and run a newer version of RAndFriendsSetup.


Personal Tools