python—为什么rpy2不将numpy数组转换为R矩阵?
发布时间:2022-05-28 05:35:36 220
相关标签: # node.js
我继承了一些使用rpy2的代码。然而,用于将numpy数组转换为R矩阵的命令不起作用,我无法找出原因或解决方法。
import numpy as np
import rpy2.robjects as ro
dist_square = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
assert dist_square.ndim == 2
assert dist_square.shape[0] == dist_square.shape[1]
# convert distance matrix to R
m = ro.vectors.Matrix(dist_square)
运行上述代码会产生以下错误:
m = ro.vectors.Matrix(dist_square)
TypeError: Matrix() takes no arguments
为什么会出现这种错误?是否有办法纠正/避免这种错误?
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报