I don't think there is a cbind-equivalent in Rcpp, but you can do

cbind1 <- cppFunction("NumericMatrix cbind1 (NumericVector x, NumericVector y){
  NumericMatrix out (x.size(), 2);
  out(_,0) = x; out(_,1)=y;
  return out;
}")

cbind1(1:5, 2:6)

     [,1] [,2]
[1,]    1    2
[2,]    2    3
[3,]    3    4
[4,]    4    5
[5,]    5    6

regards
Søren

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Hideyoshi 
Maeda
Sent: 6. februar 2014 18:13
To: [email protected]
Subject: [Rcpp-devel] cbind column(s) or rbind row(s) to a NumericMatrix

Is there a way to cbind column(s) or rbind row(s) to a NumericMatrix in Rcpp?

I have made a NumericVector that is the same length as the number of rows of a 
NumericMatrix, and was wondering how to (c)bind them together.

Thanks

HLM
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to