I was trying to use a function that not accept
by() (in particular https://github.com/JuliaInterop/RCall.jl/issues/167). I found that there is not way to get a
DataFrame from a
SubDataFrame. It would be great to have a convert method to use in this kind of cases (even if it generates copies).
I thought we had a converter at one time. Anyway, it’s easy to write:
todf(x::SubDataFrame) = x.parent[x.rows,:]
It does make copies. To avoid copies, you could convert to a DataFrame where each column is a view into the original.That’s a bit more work, so consider that an exercise for the reader .
Actually, the column view version is pretty easy, too. Note: not tested much.
todfview(x::SubDataFrame) = DataFrame(Any[view(col, x.rows) for col in x.parent.columns], names(x))