use a loop with mutate

Viewed 22084

This script works fine

F <- mutate(F, "1" = ifelse(dt == 1,1,0))

However, I'd like make a loop, because I want to apply it to 130 colums

I tried this, but it returns one extra column

for (i in 1:130) {
F <- mutate(F, "i" = ifelse(dt == i, 1, 0))
}

Can anybody help?

2 Answers
Related