【发布时间】:2016-08-22 23:46:30
【问题描述】:
我想在 R 中使用 .COM 对象来建立到 OLAP 多维数据集的 ADODB.Connection。为此,我使用了 rscproxy、rcom 和 statconnDCOM 包。
但是,我在为 rcom 包找到任何有用的文档方面并没有真正成功,因此,我在 R 中使用 .COM 对象时遇到了很大的困难。
我能够创建一个 .COM 对象,但我不知道接下来的步骤。我想做什么:
- 设置连接字符串
- 打开 R 立方体连接
- 执行 mdx 查询
请帮我解决这个问题:-)
.
代码:
# I am quite confident that this section is right:
library(rcom)
conn <- comCreateObject("ADODB.Connection")
# From now on it becomes speculative:
comGetObjectInfo(conn)
connStr = 'Provider=MSOLAP;Data Source=...;Initial Catalog=...;'
# First try to set the connection string:
comSetProperty(conn,"ConnectionString",connStr)
# Second try to set the connection string:
conn[["ConnectionString"]] = connStr
# I try to establish the connection:
conn$Open
.
其他信息:
因为我花了很长时间安装上面提到的 R-3.3.1 软件包,所以我想简要概述一下我是如何做到的:
.libPaths()
options(install.packages.check.source = "no")
install.packages(c("rscproxy","rcom"),repos="http://www.autstat.com/download",lib=.Library,type="win.binary")
installstatconnDCOM()
library(rcom)
comRegisterRegistry()
sessionInfo()
【问题讨论】: