[R] efficient way to compute a probability distribution?

Naxerova, Kamila Kamila_Naxerova at DFCI.HARVARD.EDU
Sat Aug 25 16:42:00 CEST 2007


Hello!

I have a piece of slow code and I am wondering if I am missing some obvious way
to make it faster -- or if there is some predefined function I should be using
instead.

I have a list (ranks), for which I would like to compute the probability of a
bunch of values (dereg) being contained in ranks[1:i]

prob=function(x,ranks,dereg){

	revranks=ranks[1:x]
	p=length(which(dereg %in% revranks))/length(dereg)
	return(p)
}

probdist=lapply(c(2:5166),prob,ranks=r,dereg=list)

Takes a long time... too long to do a meaningful number of permutations.

Thanks!!!
--Kamila


The information transmitted in this electronic communication...{{dropped}}



More information about the R-help mailing list