lundi 24 juillet 2017

If () statement or while () loop in R

> x=matrix(0)
> test <- vector(mode="numeric", length=196)
> for(i in 1:196){
+     x=c[c(1:(200+i*50)),]
+     ts=BiCopGofTest(x[,1], x[,2], 1, par =  0.6 ,method="white",max.df = 30, B = 0, obj = NULL)
+     test[i]=ts$statistic}
> plot(test, type='l')

I have the matrix x which has 10,000 rows and 2 columns. I took the first 200 rows of matrix x and I calculated the value of the test. Each time I was increasing the number of rows by 50 and I was calculating the test. This is what is written in the code above.

What I want to do now is the following. I want to repeat the same process but when the test is greater than 7.81 I want to stop and return the array x. I want to use the array later so it's important to store it. Should I use an IF statement or a WHILE loop? Any help will be highly appreciated.

Aucun commentaire:

Enregistrer un commentaire