[R] stalled loop

kevinchang shukai at seas.upenn.edu
Sun Sep 16 17:46:53 CEST 2007


Hey everyone,

The code I wrote executes correctly but  is stalled seriously. Is there a
way to hasten execution without coming up with a  brand new algorithm
?please help. Thanks a lot for your time.


#a simplified version of the code

a<-c("superman" , "xman" , "spiderman" ,"wolfman" ,"mansuper","manspider" )
b<-sapply(a,function(.srt){paste(sort(strsplit(.srt,'')[[1]]),
collapse="")})
c<-NA 
for(i in 1:length(b)) {
if(length(which(b==b[i]))>1)
c[i]<-b[i]
}
c<-c[!is.na(c)]
# But if my get the volumne of "a" up to about 150000 words , the loop will
work incredibly slowly.

-- 
View this message in context: http://www.nabble.com/stalled-loop-tf4456879.html#a12708590
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list