jeudi 23 février 2017

Loop in R repeating each i in a loop and then move to the i+1 and so on

Loop repeating each i in a loop and then move to the i+1 and so on

Ang1

0.063

0.072

0.077

I have a column named Ang1. I want to repeat each value few times and then move to the next value. I wrote following loop but it is repeating all sequence at once instead of one value at a time.

for (i in Ang1){
  k=rep(i, 3)
}

Output should be like that

Ang1

0.063

0.063

0.063

0.072

0.072

0.072

0.077

0.077

0.077

I have a huge data set where each value need to be repeated more than 1000 times, before I move to the next value (i+1)

Aucun commentaire:

Enregistrer un commentaire