On 05/17/2010 06:01 PM, Lorenzo Cattarino wrote:
Hi r-users,

I have a matrix B and a list of 3x3 matrices (mylist). I want to
calculate the quantiles in the list using each of the value of B as
probabilities.



The codes I wrote are:



B<- matrix (runif(12, 0, 1), 3, 4)

mylist<- lapply(mylist, function(x) {matrix (rnorm(9), 3, 3)})



for (i in 1:length(B))

{

   quant<- lapply (mylist, quantile, probs=B[i])

}



But quant returned the quantiles calculated using only the last value
([3,3]) of the matrix B.


Hi Lorenzo,
This works for me:

B<-matrix (runif(12,0,1),3,4)
mylist<-list()
for(i in 1:3) mylist[[i]]<-matrix(rnorm(9),3,3)
myq<-list()
for(i in 1:3)myq[[i]]<-quantile(mylist[[i]],probs=B[i,])

Although looking at your example, I may have misunderstood what you want the result to be.

Jim

______________________________________________
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.

Reply via email to