[R] Retrieve hypergeometric results in large scale

2012-10-01 Thread jas4710
I'm going to use dhyper(x, m, n, k) to get a 95% coverage. Let me use an example to explain my problem: Suppose I have a urn containing 90 red and 10 black balls. Now I wanna remove 3 from the urn. By the following codes: m-90;n-10;k-3; x-0:3 dhyper(x,m,n,k) I can obtain the probability

Re: [R] Retrieve hypergeometric results in large scale

2012-10-01 Thread jas4710
Thanks Jeff The documentation pages, if I haven't missed any crucial points, illustrate how to get probability and cumulative probability values. I can first retrieve the data structures and use Perl (I don't know how to use R...) to sort the derived ratios and sum the probability values until

Re: [R] Retrieve hypergeometric results in large scale

2012-10-01 Thread jas4710
Hi Bert. This is not a homework. If I can do some basic programming in R like Perl, then I'll have a better chance to accomplish this task but the matrix concept is not quickly comprehensible... -- View this message in context:

Re: [R] Retrieve hypergeometric results in large scale

2012-10-01 Thread jas4710
Thanks Jeff~~~ In fact I do not know how to combine and extract vectors in R. ans-sort(dhyper(x, m, n, k),decreasing=TRUE) rbind(ans,cumsum(ans) will show the first point that exceeds 95% threshold. The problem is: *information is lost* I can no longer identify where are the first few elements

[R] how to loop through variables in R?

2010-11-22 Thread jas4710
After importing a table with M variables and N records, I'd like to calculate chi-square statistics, say, between N1, N2; N1, N3, ..., N1, Ni, and then N2, N3, ... N2, Ni, ..., Ni-1, Ni. Two loops should be ok but the manual online help don't show a systematic way to do so but instead show