This is not a well-posed Rcpp question as
- matrix and data.frame are _fundamentally_ two different data types
- matrix being _one_ and only one storage type, or class, stored
as one vector with dimension attribute of size two for rows and cols;
this makes it _efficient_ and you will see a m
It is not possible to convert a data frame to a matrix without copying data.
But normally algorithms that need a matrix become noticeably less efficient
when applied to data frames. If this is your case, I would simply encourage the
user to pass a matrix into your function in the first place. Th
Uhm
Converting from one to other copy data? From dataframe to matrix at least?
Em sáb., 30 de abr. de 2022 às 14:26, Jeff Newmiller <
jdnew...@dcn.davis.ca.us> escreveu:
> A data frame is designed to represent different types in different
> columns. A matrix is designed so that all elements are t
A data frame is designed to represent different types in different columns. A
matrix is designed so that all elements are the same.
It sounds like you need matrices for your algorithm. I would simply require
that... or attempt to convert it immediately and stop if the result is not
numeric.
O
Hi folks!
What's the best pratices to accept a dataframe and numericmatrix in a function?
Should I have two different methods to deal with NumericMatrix and DataFrame?
Could I convert DataFrame to matrix? What's the impact of doing this,
i.e. does the as.matrix copy dataframe data?
Thanks in adv