Hello,

I want to calculate the variance of a subset of a matrix column.

For example, if I wanted the variance of items 3-10 in column 5.

In R, this would be:

x <- matrix(rnorm(100), nrow=10, ncol=10)
varx <- var(x[3:10,5])

In Rcpp, I can construct a matrix object Rcpp::NumericMatrix x
The var function is available thanks to the great Sugar implementation

But, how can I easily reference a subset of a column to calculate the variance?

Ideas?


--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building #8208
Los Angeles, CA 90095

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

Reply via email to