[R] when to use `which'?

Sam Steingold sds at gnu.org
Tue Jul 12 22:17:11 CEST 2011


when do I need to use which()?
> a <- c(1,2,3,4,5,6)
> a
[1] 1 2 3 4 5 6
> a[a==4]
[1] 4
> a[which(a==4)]
[1] 4
> which(a==4)
[1] 4
> a[which(a>2)]
[1] 3 4 5 6
> a[a>2]
[1] 3 4 5 6
>

seems unnecessary...

-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 11.0.60900031
http://jihadwatch.org http://palestinefacts.org http://mideasttruth.com
http://truepeace.org http://thereligionofpeace.com
Good programmers treat Microsoft products as damage and route around it.



More information about the R-help mailing list