Displaying 1 result from an estimated 1 matches for "id_100".
Did you mean:
id100
2011 Feb 24
2
create dummy variables by for loop
HI, Dear R community,
I try to create 100 dummy variables like the following:
ack$id_1 <- (ack$ID==1)*1
ack$id_2 <- (ack$ID==2)*1
..
.
ack$id_100 <- (ack$ID==100)*1
I used the following codes:
for(i in 1:100){
ack$id_[i] <- (ack$ID==i)*1
}
But only one column is created, can anyone help me?
Thanks a lot!
--
Sincerely,
Changbin
--
[[alternative HTML version deleted]]