In the R language, I have an S4 DataFrame consisting of Rle encoded elements.
The data can be simulated using following code
x = DataFrame(Rle(1:10),Rle(11:20),Rle(21:30))
Now, I want to convert this DataFrame to a sparse matrix from the Matrix package. On a usual data.frame, one can do
However, this does not work for DataFrames, as it gives the following error:
`Error in as.vector(data) : ` ` no method for coercing this S4 class to a vector`
Matrix(as.data.frame(x)) does not work as it gives the following error:
Error in asMethod(object) : invalid class 'NA' to dup_mMatrix_as_geMatrix
Any ideas on how to convert between data types in a rather efficient way?