如何在R v3中访问Windows COM对象? [英] How can I access Windows COM objects in R v3?

查看:310
本文介绍了如何在R v3中访问Windows COM对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前段时间,您曾经可以安装(例如,访问外部程序)中的r-if-the-com-object-is-exposed-fro> rcom )很抱歉,似乎已停用


程序包'rcom'已从CRAN存储库中删除。



可以从存档中获取以前可用的版本。 / p>

这取决于statconnDCOM,它现在限制使用,相反
对于具有FOSS许可证的包的CRAN策略。请参阅
http://rcom.univie.ac.at/ http://www.statconn.com/


按照归档和statconn链接并在R版本3中安装旧版本时会出现错误:


错误:package'rcom' 3.0.0:请重新安装
it。


我不太熟悉R,方式周围这个消息 - 毕竟,它发生在安装时,所以重新安装似乎不是答案。看起来好像 rcom 根本不适用于最近的(3.0+)版本的R.我还扫描了打包列表,虽然搜索COM会返回一百个结果,当点击它们时,我可能错过了一个。



我如何使用 rcom 包或使用R内的COM? / p>

(注意:我代表一个同事问这个问题,我没有R的经验,我们都在寻找答案时找不到)

解决方案

我看着rcom源代码几个月前。看来我可以得到它来构建和安装在R3.0.1上确定。以下是有帮助的程序。




  • 获取rcom的最新源代码。我本地有rcom_2.2-5.tar.gz。我可以在以下地址google的东西,但我不知道的出处,所以由你检查它是合法的。 http://cran.open-source-solution.org/web/packages/rcom/ index.html

  • 在R中 install.packages('rscproxy')

  • 按照R网站上的说明安装Rtools( http://cran.r-project.org) / bin / windows / Rtools ),

  • 打开Windows命令提示符,即运行CMD

  • 包含'rcom'文件夹的文件夹,并在命令提示符下:

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


  • 检查通过时没有太多投诉。您对-no-manual选项的呼叫(如果安装了MiKTeX,您可以删除它)

     %R%CMD INSTALL rcom 






 安装到c:/ Rlib / rcom / libs / i386 
** R
** inst
**准备包延迟加载
**帮助
***安装帮助索引
**构建包索引
**测试如果已安装的包可以加载
rcom需要安装当前版本的statconnDCOM。
要安装statconnDCOM类型
installstatconnDCOM()
这将下载并安装statconnDCOM的当前版本
您将需要一个可用的Internet连接
,因为安装需要下载文件。
* DONE(rcom)




  •   library(rcom)
    installstatconnDCOM()


  • 我尝试了一个 comRegisterRegistry(); comRegisterServer()
    ; x< -comGetObject(Excel.Application)
    但我得到一个NULL为 x 。我不是rcom的用户,所以看起来编译正常;




如果您碰巧需要访问.NET代码,是我有既得利益,可以提到它)可能是 rClr 包。



希望这有助于;我很想知道你去哪儿。


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!)

解决方案

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.

这篇关于如何在R v3中访问Windows COM对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆