Description
I've been working on an implementation for a cbind
sugar function, but since my current design lacks some of the features of base::cbind
I'm not sure it's on par with the rest of the Rcpp::sugar
functions, and was hoping to get some feedback and / or suggestions for improving it. The source can be viewed in this gist (I didn't want to dump 300 lines of code into this ticket), but to summarize the pros and cons:
Good:
- Handles
Matrix
/Matrix
,Matrix
/Vector
,Matrix
/scalar
,Vector
/Vector
,Vector
/Matrix
,Vector
/scalar
,scalar
/Matrix
,scalar
/Vector
argument pairs - Does appropriate checking for equal number of rows (or length(s), in the case of
Vector
s)
Shortcomings:
- Does not handle arbitrary number of arguments in a single function call, as in
base::cbind
's...
argument (I'm not sure how to address this without dipping into C++11, or if it's even possible in C++98) , although nested calls seem to work correctly (e.g.cbind(cbind(cbind(arg1, arg2), arg3), arg4)
) - The
dimnames
attribute is not preserved - Does not handle
DataFrame
s
From the testing I've done so far, the supported features above correctly mimic the behavior of base::cbind
, but I'm not sure what the general consensus is on including less-than-comprehensive sugar functions in the package. Is it worthwhile to have a version of cbind
with limited functionality? And of course, I'd be more than happy to look into any suggestions for improving this.