> The reason R is powerful is becasue it can handle large vectors without each > element being manipulated? Please let me know where I am wrong. > > for(i in 1:length(news1o)){ > + if(news1o[i]>s2o[i]) > + s[i]<-1 > + else > + s[i]<--1 > + }
You might give ifelse() a shot here. s <- ifelse(news1o > s2o, 1, -1) Learning to think in vectors is important in R, just like thinking in sets is important for SQL, or thinking in rows and steps is important in SAS. cur -- Curt Seeliger, Data Ranger Raytheon Information Services - Contractor to ORD seeliger.c...@epa.gov 541/754-4638 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.