Allow c(1,5:9) type syntax in formula

Also fixed a bug in .gsub for as.factor and factor, which may lead to
infinite loop.