Dear R users, In the code below, I am trying to print the result of my loop function. The output first gives me the result for k=1, and then for k=1 and k=2. I only want the last output which is
[,1] [,2] [1,] 0.1700065 0.5002659 [2,] 0.3080273 0.4954731 [3,] 0.4844886 0.4544306 [4,] 0.5062987 0.1868154 [5,] 0.5846982 0.4353522 [6,] 0.4332621 0.2202922 [7,] 0.4391985 0.2424147 [8,] 0.4242643 0.2372497 [9,] 0.3274367 0.3664741 [10,] 0.1937940 0.4192495 How can I extract only this part of my output. Thank you very much in advance. d<-matrix(c(1,1,0,0,0,0,0,0,2,1,0,0,1,1,0,1,2,2,1,0),nrow=10,ncol=2) h<-matrix(runif(20,0,1),10) int<-matrix(c(0),nrow=10, ncol=2) for (k in 1:2){ for(s in 1:10){ integrand<-function(x) x^d[s,k]*exp(-x*gamma(1+1/1.6))^1.6*exp(-x*h[s,k]) integ[s,k]<-quadgk(integrand,0,1000) } print(int) } [,1] [,2] [1,] 0.1700065 0 [2,] 0.3080273 0 [3,] 0.4844886 0 [4,] 0.5062987 0 [5,] 0.5846982 0 [6,] 0.4332621 0 [7,] 0.4391985 0 [8,] 0.4242643 0 [9,] 0.3274367 0 [10,] 0.1937940 0 [,1] [,2] [1,] 0.1700065 0.5002659 [2,] 0.3080273 0.4954731 [3,] 0.4844886 0.4544306 [4,] 0.5062987 0.1868154 [5,] 0.5846982 0.4353522 [6,] 0.4332621 0.2202922 [7,] 0.4391985 0.2424147 [8,] 0.4242643 0.2372497 [9,] 0.3274367 0.3664741 [10,] 0.1937940 0.4192495 -- View this message in context: http://r.789695.n4.nabble.com/for-loop-output-tp4646496.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.