[R] Efficiently create dummy

Rob Denniker bearmarketsrule at inbox.com
Mon Mar 23 10:44:00 CET 2009

What's the neat way to create a dummy from a list?
The code below is not replicable, but hopefully self-explanatory...


notreat<-c("AR", "DE", "MS", "NY", "TN", "AK", "LA", "MD",  "NC", "OK", "UT", "VA")

#i would really like this to work:

#but instead i resort to this
for (i in 1:length(notreat)) {
temp.st <- notreat[i]
i<-i+1 }

Thanks, list!

More information about the R-help mailing list