jeudi 22 septembre 2016

R - Expanding Product Based on Previous Result

I am relatively new to R and am trying to write a code for:

c=n1(n1-R_1-1)(n1-R_1-R_2-2)...(n1-R_1-R_2-...-R_{m1-1}-m1+1)

I essentially want to create a vector containing all possible values of c. Note that n1 and m1 are fixed values.

Here is my attempt:

c[j]<- for (j in 1:m1)
{
 if (c==1) {n}
 else (c>1) {n(n-R_1-1)}
}

I know this is wrong. I am struggling with the structure. Any help would be much appreciated. Thanks.

Aucun commentaire:

Enregistrer un commentaire