1

我想将数据从 Spotfire 传递到 R,然后显示由 R 构建的图。
最好的方法是什么?

4

2 回答 2

1

我已经想出了将图像放入 Spotfire 的技巧。如果您遵循这些指示并不难,但它的完成方式与您在 Spotfire 中的猜测方式截然不同,这就是为什么我花了一段时间才弄清楚的原因。

以下是如何执行此操作的概述。您创建一个 DocumentProperty,它是一个二进制对象,编写一些 Spotfire 代码为该 Document Property 赋值,然后使用“Label”类型的 Spotfire Property Control 显示该二进制对象。

令人困惑的部分是您根本不使用 Spotfire“插入图像”工具,并且您根本不使用在 Spotfire 中的 R 代码中生成的文件名。一旦您习惯了您认为在 Spotfire 中解决问题的两种最明显的方法完全无用且错误的想法,您就可以取得一些进展。

我将省略蜘蛛图的细节,因为代码很长。

这就是你要做的。

1) 在 Spotfire 中创建一个“Binary”类型的文档属性,例如,“imageThatGoesBackToSpotfire” 2) 您编写一些 R 代码来生成图像并将其写入文件:

# get a temporary directory name on the local machine.  You wouldn’t need to do this is you were just
# going to run it on your own, but you need to do it if you intend to let anybody else run it on their own machine.
tempfilebase = tempfile()
# take the tempfilebase and prepend it to a filename.
myFilename<-“someFileName.jpg”
myFullFilename <- paste(tempfilebase,myFilename,sep="")
#open a jpeg
jpeg(filename=myFullFileName)
# generate the image, however you normally would in R
plot(input)
# close the file
dev.off
# open a connection to that file.
myConnection<-file(myFullFileName,open=”rb”)
imageThatGoesBackToSpotfire<- data.frame(r=readBin(myConnection, what="raw", n=(file.info(myFullFileName)$size)))
close(myConnection)

3) 运行上面的 R 脚本。选择一些作为绘图“输入”的列,并使 R 脚本将输出返回到“imageThatGoesBackToSpotfire”DocumentProperties。4) 在 Spotfire 中创建一个文本区域。5) 将属性控件插入“标签”类型的文本区域。(点击下图中圈出的图标)。这将打开一个对话框,

于 2014-12-19T21:23:31.407 回答
0

You need to register a data function with inputs and outputs, and the specific PNG data needs to be returned as a binary label.

Some details: http://spotfire.tibco.com/tips/2014/02/25/dynamically-displaying-images-in-a-text-area/

于 2014-10-23T03:14:11.353 回答