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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -