I am having difficulty with this seemingly simple operation that I’d assume has been solved previously but I cannot find any examples.
In the R environment @data is of type DataFrame but rpy2 (2.2) is returning a Matrix. Is there a convirent way to either convert m to a DataFrame or to have the robjects.r(query) return a DataFrame?
from rpy2.robjects.packages import importr
import rpy2.robjects as robjects
fimport = importr('fImport')
yahooImport = robjects.r('function(x) yahooImport(x)@data')
qqq = yahooImport("QQQ")
print type(qqq)
You can try explicitly casting to a data.frame in your yahooImport function.
The following worked for me:
yahooImport returns a timeSeries object which is represented internally as a matrix, which is what is causing your return values in rpy2 to be a matrix.