Hi: Try this:
> z <- matrix(rnorm(100), nrow = 10) > sum(sapply(seq_len(nrow(z)), function(k) det(z[-k, -k]))) [1] 1421.06 where > sapply(seq_len(nrow(z)), function(k) det(z[-k, -k])) [1] 432.11613 81.65449 516.95791 54.72775 804.32097 -643.35436 [7] -411.15932 394.18780 84.13173 107.47665 HTH, Dennis On Tue, Aug 2, 2011 at 5:18 AM, john james <dnt...@yahoo.com> wrote: > Dear R-help list, > Pls I have this problem. Suppose I have a matrix of size nxn say, generated > as follows > > z<-matrix(rnorm(n*n,0,1),nrow=n) > > I want to write a function such that for i in 1:n, I will remove the rows and > columns > corresponding to i (so, will be left with n-1*n-1 submatrix in each cases). > Now I need > the sum of the determinant of each of this submatrices. As an example, if > n=3, it means I will have det(1strow and 1stcolum removed) + det(2ndrow and > 2ndcolum removed) + det(3rdrow and 3rdcolum removed). > > Any help will be appreciated. Thanks > > John > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.