Skip to content
Prev 247198 / 398503 Next

easy loop question

On Jan 12, 2011, at 10:54 PM, Sebasti?n Daza wrote:

            
You CANNOT use names like that. (It makes no sense to supply a vector  
argument to "$".) If you want to change every instance of 3 within  a  
group of columns. See if this works

est8vo[, 77:83] <-  sapply( est8vo[, 77:83], function(x) ifelse(x==3,  
99, x) )
est8vo[, 77:83] <- sapply(est8vo[, 77:83] , factor, labels=c("vac?o",  
"s?", "no", "doble marca"))
Wrong. Wrong. Wrong. And please forget about using "$" inside loops in  
the left-hand side. It is not designed for that.
David Winsemius, MD
West Hartford, CT