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

November 15, 2010


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
(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)
i <- which(x > a)
identical( x[-i], x[!x > a] )

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.

Search Revolutions Blog

Got comments or suggestions for the blog editor?
Email David Smith.
Follow revodavid on Twitter Follow David on Twitter: @revodavid
Get this blog via email with Blogtrottr