<$BlogRSDUrl$>

Wednesday, October 22, 2008

Does R have a for. . .each loop or just for loops?

Just a for loop as far as I know

Also, is there a way to get the index of a certain value in a vector/array/matrix/etc? For example you have vbl <- c(3,5,7,2,6) and you want to figure out what position 7 is in.

Check out the "which" function:

a<-c(1,2,3,4,5,6,9,8)
which(a==9)
[1] 7


This page is powered by Blogger. Isn't yours?