前一段时间,您曾经能够安装 rcom package in R to use COM scripting(例如,访问外部程序。)不幸的是,它是seems to be discontinued:



跟随archive和statconn链接并在R版本3中安装一个较旧的版本会出现错误:



我对R不太熟悉,但是似乎无法解决此消息-毕竟,它是在安装时发生的,因此重新安装似乎不是解决方案。似乎rcom对于R的最新版本(3.0+)根本不可用。我还扫描了package list,尽管搜索“COM”会返回一百多个结果,并且单击时可能错过了正确的结果他们。

如何使用rcom包,或以其他方式从R中使用COM?

(注意:我代表一个同事问这个问题。我自己从没有R的经验。我们两个人在寻找答案时都找不到任何东西。我敢肯定,其他人也都在使用COM。不过是R版本!)

最佳答案

几个月前,我看了看rcom的源代码。看来我可以在R3.0.1上构建并安装OK。如果有帮助,请执行以下步骤。

  • 获取rcom的最新源代码。我在本地有rcom_2.2-5.tar.gz。我可以在以下地址搜索一些东西,但是我不知道出处,所以您可以检查一下它是否合法。 http://cran.open-source-solution.org/web/packages/rcom/index.html
  • R中的
  • install.packages('rscproxy')
  • 按照R网站(http://cran.r-project.org/bin/windows/Rtools),
  • 上的说明安装Rtools
  • 打开Windows命令提示符,即运行“CMD”
  • 转到包含“rcom”文件夹的文件夹,并在命令提示符下:
    set R="c:\Program Files\R\R-3.0.1\bin\i386\R.exe"
    %R% CMD check --no-manual rcom
    
  • 检查它是否通过,没有太多提示。关于--no-manual选项的调用(如果安装了MiKTeX,则可以将其删除)
    %R% CMD INSTALL rcom
    

  • 应该导致
        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)
    

    R中的
  • :
    library(rcom)
    installstatconnDCOM()
    
  • 我尝试了comRegisterRegistry() ; comRegisterServer(); x<-comGetObject("Excel.Application"),但x却为NULL。我不是rcom的用户,因此尽管看起来一切正常。它可能不再工作了。

  • 如果您碰巧需要访问.NET代码,则可以使用rClr软件包(是的,我有幸提及它)。

    希望这可以帮助;我很想听听你的情况。

    10-05 21:23