简体   繁体   English

在 python 块中调用 R object 时出错(R 降价)

[英]Error when calling an R object in a python chunk (R markdown)

enter image description here I am using the library reticulate to run some python code in RStudio.在此处输入图像描述我正在使用库 reticulate 在 RStudio 中运行一些 python 代码。 The syntax to call an R object in a python chunk is: r.object. The syntax to call an R object in a python chunk is: r.object. Unfortunatly I have this error message when calling my r.object in the python code portion... (screenshot below).不幸的是,在 python 代码部分中调用我的 r.object 时,我收到此错误消息...(下面的屏幕截图)。 Also I am running my code on an rstudio instance on an amazon cloud (should not pose a problem...) Do not really understand why...我也在亚马逊云上的 rstudio 实例上运行我的代码(不应该造成问题......)不太明白为什么......

Thanks in advance for helping:)在此先感谢您的帮助:)

You will also find the R code portion that comes right before i run the python chunk enter image description here您还将在我运行 python 块之前找到 R 代码部分 在此处输入图像描述

It's hard to know what your trying to do, but I can help you read the error.很难知道您要做什么,但我可以帮助您阅读错误。

You can see that the error is coming from line 10 which is this one:您可以看到错误来自第 10 行,即这一行:

for f in r.test_idx.keys():

You don't have any object before this line that instantiates r.在实例化 r 的行之前,您没有任何 object。 As far as the code is concerned, r does not exist and you are trying to call the test_idx.keys() method from the r object.就代码而言, r不存在,您正在尝试从r object 调用test_idx.keys()方法。

There's actually nothing in the for loop that references anything outside of it.实际上,for 循环中没有任何内容可以引用它之外的任何内容。

Are these values defined in the R chunks of the code?这些值是否在代码的R块中定义?

If so, can you post the R chunks that precede this and I can help further.如果是这样,您能否发布之前的R块,我可以进一步提供帮助。

Kind Regards亲切的问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM