我的目标是从Python到R到R中的unserialize
获取字节数据
import rpy2.robjects as ro
rcode = 'serialize(iris, NULL)'
r_res = ro.r(rcode)
print(type(r_res[0]))
# <class 'bytes'>
# Works up to here, not sure what how to get the 'bytes' type back into R
# Got 24 from the Rinternals.h file where it indicates RAWSXP
rawsxp_rinternals = 24
r_vec = ro.SexpVector(r_res[0], rawsxp_rinternals)
这将产生以下错误:
Error while converting to Bytes element 0.
理想情况下,我希望实现以下目标
R的
serialize()
返回字节向量列表。这是unserialize()
所期望的输入。以下内容将“起作用”:否则,构建rpy2
Vector
(对于RRAWSXP
向量)可以像对于其他向量一样实现:相关问题 更多 >
编程相关推荐