Skip to content
Prev 181068 / 398503 Next

Loop avoidance and logical subscripts

Hello!

I'm writing a script with a lot of loops and it executes really slowly over
huge amounts of data. I assume it's because I don't know how to avoid using
loops. Logical subscripts are more desirable, but I don't know how to
implement them. One example of that issue:

library(seqinr)
GCsequence <- vector()
	for( i in 1:(length(data$sequence))) {
		c(GCsequence,GC(s2c(data$sequence[i])))->data$GCsequence[i]
	}
	rm(GCsequence)

How should I speed up that? 

Thank you, 

Retama