« Because it's Friday: Asteroids | Main | In case you missed it: October Roundup »

November 15, 2010

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a010534b1db25970b0133f52b8422970b

Listed below are links to weblogs that reference Loops in R: Think different:

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

All true. However, sometimes for loops are much easier to read if the performance penalty isn't too bad.

a powerful function I really like is which()
i <- which(x > a)
in combination with
x[-i]
(i<0!) loops often can be avoided

@wactbprot, why do you need which()? Why not just use the negation operator on your logical vector?
Try this:

x<-sample( 1:10, 50, replace=TRUE)
a<-5
i <- which(x > a)
identical( x[-i], x[!x > a] )

@TM
I need which() here because I don't want to preach to the converted. Thats all.
The post we comment her speaks to "programmers that come to R from other languages". Don't you think that which() is a command "programmers that come to R from other languages" should look on?

I came across the foreach package it has parallel processing capabilities.

The comments to this entry are closed.


R for the Enterprise

Got comments or suggestions for the blog editor?
Email David Smith.
Follow revodavid on Twitter Follow David on Twitter: @revodavid

Search Revolutions Blog