启动Excel时Rexcel出错 [英] Error with Rexcel when starting up Excel
问题描述
然后还有一些更多的错误...一切都正常工作之前..有人有什么想法可能是什么问题吗?
另一个奇怪的是,之后Rapply等工作..但是当我收到错误关闭工作簿。
所以当我从Excel中的Rexcel meny中我 startR
出现问题。
编辑:
感谢$ code> flodel 为他的答案。但是现在无法运行Sub还是不可能?
Sub create_efficient_frontier()
RInterface .StartRServer
Sheets(Analys)。Range(A52:K82)。ClearContents
RInterface.PutDataframedatat,Range(ChosenData!X181:AD352 )
RInterface.PutArraystartdate,Range(Analys!K2)
RInterface.PutArrayenddate,Range(Analys!K3)
RInterface。 RunRFileC:/Users/Documents/EffFront.R
RInterface.GetDataframehmz $ pweight,Range(Analys!A51:E76)
End Sub
我在行
<$ c $时收到运行时错误13(不兼容类型) c> RInterface.GetDataframehmz $ pweight,Range(Analys!A51:E76)
昨天工作,见使用Rexcel运行宏
解决方案:
Ctrl + Alt + Shift + F9似乎工作:)
最好的问候
是的。我自己一直在努力。很可能您的计算必须以特定的顺序计算。通常,您的某些( RApply
, REval
等)调用创建一些数据(例如 x< - 10
),以后的调用将期望数据存在:compute x ^ 2
。
当您从头开始制作传染药时,一切都可以正常工作。问题是,当您保存并重新打开它时,Excel不知道计算单元格所需的顺序:它通过以稍微随机的顺序触发单元格计算来计算其依赖关系树。那么发生的是这个单元格应该计算 x ^ 2
可能会在您的R中创建 x
的单元格之前运行环境,这会触发错误。
这是令人讨厌的,但正如你所注意到的那样,Excel可以构建其依赖关系树后最终会消失。如果您绝对需要找到解决该问题的解决方案,则必须使用VBA代码来帮助Excel以非常特定的顺序构建其依赖关系树。
Today something happened (never had this problem before) when I start up Excel workbook where I use Rexcel.
And then there are some more errors... Everything worked properly before.. Does anyone have an idea about what the problem could be?
The other strange thing is that after that the Rapply and so on works.. But I get errors again when I close workbook.
So the problem appears when I startR
from Rexcel meny in Excel.
EDIT:
Thanks to flodel
for his answer. But is it not possible to run the Sub below now or?
Sub create_efficient_frontier()
RInterface.StartRServer
Sheets("Analys").Range("A52:K82").ClearContents
RInterface.PutDataframe "datat", Range("ChosenData!X181:AD352")
RInterface.PutArray "startdate", Range("Analys!K2")
RInterface.PutArray "enddate", Range("Analys!K3")
RInterface.RunRFile "C:/Users/Documents/EffFront.R"
RInterface.GetDataframe "hmz$pweight", Range("Analys!A51:E76")
End Sub
I get runtime error 13 ("incompatible types") at line
RInterface.GetDataframe "hmz$pweight", Range("Analys!A51:E76")
That worked yesterday, see Run macro with Rexcel
Solution:
Ctrl+Alt+Shift+F9 seems to work:)
Best Regards
Yes. I have struggled with this myself. Most likely your computations must be computed in a specific order. Typically, some of your (RApply
, REval
, etc.) calls create some data (e.g. x <- 10
) in the R session and later calls will expect that data to exist: compute x^2
.
Everything works fine when you build your spreadhseet from scratch. The problem is that when you save it and reopen it, Excel does not know in what order it needs to compute your cells: it figures out its dependency tree by firing out cell computations in a somewhat random order. So what happens is the cell supposed to compute x^2
might be run before the cell that creates x
in your R environment, which triggers an error.
This is annoying but as you noticed, the errors do eventually go away after Excel is able to build its dependency tree. If you absolutely need to find a solution to that problem, it will have to involve VBA code to help Excel build its dependency tree in a very specific order.
这篇关于启动Excel时Rexcel出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!