Rpy2找不到函数
我四处寻找错误无法找到函数“someFunction”,这似乎是一个常见错误,但是我没有发现任何与 Rpy2 有关的错误。我想从用 python 制作的矩阵制作热图。
def HeatMap(HeatData):
RHeatMap = robjects.FloatVector([HeatData[i] for i in range(len(HeatData[:,1]))])
HeatMap = robjects.r['matrix'](RHeatMap, nrow = len(HeatData[:,1]))
robjects.r('HeatMap = %s' %HeatMap.r_repr())
robjects.r('jsr.colors=colorRampPalette(c("green","black","red"),interpolate="linear")')
robjects.r('heatmap(HeatMap, Rowv = NA, Colv = NA, col = topo.colors(100))')
该错误是由最后两行引起的,但在 RI 中这两个函数都没有问题。
谢谢
I've looked around for the error could not find function "someFunction" it appears to be a common error, however I have not found any pertaining to Rpy2. I want to make a heat map from a matrix I made in python.
def HeatMap(HeatData):
RHeatMap = robjects.FloatVector([HeatData[i] for i in range(len(HeatData[:,1]))])
HeatMap = robjects.r['matrix'](RHeatMap, nrow = len(HeatData[:,1]))
robjects.r('HeatMap = %s' %HeatMap.r_repr())
robjects.r('jsr.colors=colorRampPalette(c("green","black","red"),interpolate="linear")')
robjects.r('heatmap(HeatMap, Rowv = NA, Colv = NA, col = topo.colors(100))')
The error is caused by both of the last 2 lines however in R I have no problem with either function.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在Python2.7和rpy2 2.1.9下对你的代码没有任何问题。
如果直接调用 R 函数而不是使用字符串会发生什么?
I do not have any problems with your code under Python2.7 and rpy2 2.1.9.
What happens if you call the R functions directly instead of using strings?