Re: [R] R [coding : do not run for every row ]

2016-04-18 Thread tan sj
2016 10:03 AM To: tan sj; r-help@r-project.org Subject: Re: [R] R [coding : do not run for every row ] Always keep the mailing list in cc. The code runs for each row in the data. However I get the feeling that there is a mismatch between what you think that is in the data and the actual data. i

Re: [R] R [coding : do not run for every row ]

2016-04-18 Thread Thierry Onkelinx
em like the problem of looping through data is still the > samei am really wondering where is the mistake > > > From: Thierry Onkelinx > Sent: Monday, April 18, 2016 7:21 AM > To: tan sj > Cc: r-help > Subject: Re: [R] R [coding :

Re: [R] R [coding : do not run for every row ]

2016-04-18 Thread tan sj
Hi, i am sorry, the output should be values between 0 and 0.1 and not supposed to be 1.00, it is because they are type 1 error rate. And now i get output 1.00 for several samples,rhis is no correct. The loop do not run for every row. i do not know where is my mistake. As i use the same concept

Re: [R] R [coding : do not run for every row ]

2016-04-18 Thread Thierry Onkelinx
You can make this much more readable with apply functions. result <- apply( all_combine1, 1, function(x){ p.value <- sapply( seq_len(nSims), function(sim){ gamma1 <- rgamma(x["m"], x["sp(skewness1.5)"], x["scp1"]) gamma2 <- rgamma(x["n"], x["scp1"], 1)

Re: [R] R [coding : do not run for every row ]

2016-04-17 Thread Thierry Onkelinx
Dear anonymous, The big mistake in the output might be obvious to you but not to others. Please make clear what the correct output should be or at least what is wrong with the current output. And please DO read the posting guide which asks you not to post in HTML. ir. Thierry Onkelinx Instituut v

[R] R [coding : do not run for every row ]

2016-04-17 Thread tan sj
i have combined all the variables in a matrix, and i wish to conduct a simulation row by row. But i found out the code only works for the every first row after a cycle of nine samples. But after check out the code, i don know where is my mistake... can anyone pls help #For gamma disribu