loops - Generate 1s in place of NAs when i=2 -
i need change nas 1s when i=2, in loop. reposted question since did not have solution in r-help.
my code:
zeta <- rep(1,8) n <- 7 (i in 1:2){ beta <- zeta[1:n+(i-1)*(n+1)] print(beta) parm <- zeta[i*(n+1)] print(parm) }
the output follows:
[1] 1 1 1 1 1 1 1 [1] 1 [1] na na na na na na na [1] na
the desired outcome be:
[1] 1 1 1 1 1 1 1 [1] 1 [1] 1 1 1 1 1 1 1 [1] 1
how desired outcome?
best, moohwan
Comments
Post a Comment