? stato filtrato un testo allegato il cui set di caratteri non era indicato... Nome: non disponibile URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101030/7d59e415/attachment.pl>
For loop
3 messages · 20c, Tal Galili, Joshua Wiley
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101031/86956336/attachment.pl>
Hi, In general, the way to speed up for loops in R is to avoid them. It looks like some of the operations could be vectorized (e.g., h[1,k] + vv[j-1,k+1] looks like you could just add entire columns at once). If you provide sample data for all the variables in your loop, it will be possible to give you more detailed feedback. Cheers, Josh 2010/10/30 20c <20c at email.it>:
Hi all,
how can i make the following loop faster?
vv[20001,22]=v[20001,22]
for(k in 21:1) {
?for(j in 20001:2) {
? vv[j-1,k+1]=min(xx[j-1]*v[j-1,k+1],vv[j,k+1])
? v[j,k]=h[1,k]+vv[j-1,k+1]
?}
vv[20001,k]=v[20001,k]
}
Thanks
Lorenzo
?--
?Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f
?Sponsor:
?Idee Regalo Personalizzate a partire da euro 3.90! Su MisterCupido.com alta qualit? a prezzi imbattibili... e questa settimana GRATIS per te, la confezione regalo!
?Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=11027&d=30-10
? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/