In a related vein, is there any functionality - existant or planned -
for "fancy" indexing (that is, selecting non-continguous submatrices)
a la
X = matrix(1:24, nrow=3)
Y = X[,c(2,4,7)]
As it stands I'd create a new matrix and loop over the column indices
to populate it. Not a big deal since my
I had a bash at this as I'm currently learning some C++ / Rcpp. I made a
function where you pass in the row start index and row end index, and the
desired matrix column (which is what I assumed you would want).
Here is the code I came up with including some benchmarks I ran,
interestingly, using a
On 20 September 2011 at 23:00, Noah Silverman wrote:
| Nice suggestion, but it may not work for what I'm trying to do.
|
| I'm building up a matrix of values over a time series as part of a big loop.
| At certain iterations, I need to calculate some summary statistics on a few
| things. In R, i
On Wed, Sep 21, 2011 at 4:00 PM, Noah Silverman wrote:
> Nice suggestion, but it may not work for what I'm trying to do.
> I'm building up a matrix of values over a time series as part of a big loop.
> At certain iterations, I need to calculate some summary statistics on a few
> things. In R, it
Nice suggestion, but it may not work for what I'm trying to do.
I'm building up a matrix of values over a time series as part of a big loop.
At certain iterations, I need to calculate some summary statistics on a few
things. In R, it is trivial to subset any part of a matrix. Not sure to do
I am not sure if there are native functions in Rcpp but you could use
RcppArmadillo to solve your problem.
So say Xs = x:
// Convert from SEXP => Rcpp => Arma
Rcpp::NumericMatrix Xr(Xs);
arma::mat X(Xr.begin(), Xr.nrow(), Xr.ncol(), false);
// Get subset of matrix and calculate variance
// (i.e.