【问题标题】:RDCOMClient package: How to read data from a queryRDCOMClient 包:如何从查询中读取数据
【发布时间】:2016-08-22 16:02:27
【问题描述】:

我目前的问题是使用 .COM 对象通过 R 连接到多维数据集,然后通过 mdx 查询从多维数据集收集数据。正如我之前的问题所述(见下面的链接),我现在可以在 RDCOMClient 包和 R 版本 3.3.1 的帮助下连接到多维数据集,并且还可以向多维数据集发送查询。 此外,在跟踪我与 SQL Server Profiler 的连接时,我可以看到它连接正确 + 我还看到我的查询执行没有错误。

但是,我不知道如何在 R 中获取我的数据。我将查询结果保存在变量 results 中,但我无法用它做任何事情。你能帮我在 R 中显示我的查询结果吗?

.

连接+查询码:

conn = COMCreate("ADODB.Connection")

connStr = 'my connection string'
conn[["ConnectionString"]] = connStr 

conn$Open()
conn[["State"]]  

query = 'some query. 100% correct, tested with other tools'
results = conn$Execute(query)

.

结果变量的信息:(代码,后跟输出)

names = slotNames(results)
names 

[1] "参考"

.

slot(results,names[1])

指针:0x0000000015d63c60

.

str(results)

带有 1 个插槽的正式类 'COMIDispatch' [包 "RDCOMClient"]

..@ 参考:

.

class(results)

[1] "COMIDispatch" attr(,"包") [1] "RDCOMClient"

.

attributes(results)

$ref

$类

[1] "COMIDispatch"

attr(,"包")

[1]“RDCOM 客户端”

.

感谢您的帮助 :-)

.

上一个问题:R & COM-Objects: How to connect to a OLAP cube on Windows

【问题讨论】:

    标签: mysql r com ado rdcomclient


    【解决方案1】:

    考虑使用 ADO 的 GetRows() 方法,该方法返回嵌套 VBA 数组中记录集的记录,该数组将转换为嵌套 R 列表。目前,您只检索记录集对象。

    results = conn$Execute(query)$GetRows()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-16
      • 1970-01-01
      • 1970-01-01
      • 2015-09-28
      • 2022-11-14
      • 2022-07-05
      相关资源
      最近更新 更多